[cmor] 02/190: adding the files that were under libcdms repo
Alastair McKinstry
mckinstry at moszumanska.debian.org
Tue Jul 21 12:54:15 UTC 2015
This is an automated email from the git hooks/post-receive script.
mckinstry pushed a commit to branch debian/master
in repository cmor.
commit 52f2b5fdb96a880d99d48d62d6d6537791e2a888
Author: Doutriaux <doutriaux1 at meryem.llnl.gov>
Date: Thu Apr 29 10:47:35 2010 -0700
adding the files that were under libcdms repo
---
Src/cdTime/Makefile.in | 98 ++
Src/cdTime/cdRegTrfm.c | 139 ++
Src/cdTime/cdTimeConv.c | 1110 +++++++++++++
Src/cdTime/cdUtil.c | 46 +
Src/cdTime/fcdTimeConv.c | 118 ++
Src/cdTime/reg_trfm.c | 962 +++++++++++
Src/cdTime/timeArith.c | 179 +++
Src/cdTime/timeConv.c | 396 +++++
include/cdTime/cddrs.h | 151 ++
include/cdTime/cddrsint.h | 107 ++
include/cdTime/cdms.h | 319 ++++
include/cdTime/cdms.inc | 57 +
include/cdTime/cdmsint.h | 588 +++++++
include/cdTime/cdmsint_new.h | 1063 +++++++++++++
include/cdTime/cdrra.h | 43 +
include/cdTime/cdunif.h | 175 ++
include/cdTime/cdunifint.h | 383 +++++
include/cdTime/cdunifpp/cdunifpp.h | 1086 +++++++++++++
include/cdTime/cdunifpp/cdunifpp_frename.h | 68 +
include/cdTime/cdunifpp/crayio.h | 396 +++++
include/cdTime/cdunifpp/util.h | 251 +++
include/cdTime/cdunifpp/vardef.h | 67 +
include/cdTime/cfortran.h | 2369 ++++++++++++++++++++++++++++
include/cdTime/drscdf.h | 272 ++++
include/cdTime/drsdef.h | 203 +++
include/cdTime/fcddrs.h | 219 +++
include/cdTime/gaussLats.h | 232 +++
include/cdTime/grads.h | 1100 +++++++++++++
include/cdTime/gx.h | 442 ++++++
include/cdTime/isdb.h | 104 ++
30 files changed, 12743 insertions(+)
diff --git a/Src/cdTime/Makefile.in b/Src/cdTime/Makefile.in
new file mode 100644
index 0000000..b0a1581
--- /dev/null
+++ b/Src/cdTime/Makefile.in
@@ -0,0 +1,98 @@
+# -*-Mode: indented-text;-*-
+# Makefile: db_util makefile
+#
+# Copyright: 1996, 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$
+#
+# Revision History:
+#
+# $Log: Makefile.in,v $
+# Revision 1.2 1997/10/24 18:23:57 drach
+# - Cache netCDF unlimited dimensions
+# - Consistent with GrADS src170
+#
+# Revision 1.1 1996/09/09 18:28:31 drach
+# - Cleaned up minor compilation warnings
+#
+#
+# Note: Makefile is generated from Makefile.in by top level configure
+#
+
+# Install prefix for architecture-independent files
+prefix= @prefix@
+
+# Install prefix for architecture-dependent files
+exec_prefix= @exec_prefix@
+
+# Expanded directories
+BINDIR=$(exec_prefix)/bin
+INCLUDEDIR=$(prefix)/include
+LIBDIR=$(exec_prefix)/lib
+MANDIR=$(prefix)/man
+PARMDIR=$(prefix)/lib/lats
+
+CC = @CC@
+CFLAGS = -I../../include @CFLAGS@ $(DEBUG) -Dgrads
+CPPFLAGS = @CPPFLAGS@
+DEBUG = -O
+DEFS = @DEFS@
+FC = @FC@
+FFLAGS = -I../../include @FFLAGS@ $(DEBUG)
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+LDFLAGS = -L../../../lib -lcdms @NCOPTS@ @DRSOPTS@ @LIBS@
+OS = @OS@
+RANLIB = @RANLIB@
+
+# Shell to run make subcommands
+SHELL = /bin/sh
+
+# Do not change values below this line
+#
+LIBRARY = ../../lib/libcdms.a
+OBJS = cdTimeConv.o timeConv.o timeArith.o reg_trfm.o cdRegTrfm.o \
+ cdUtil.o
+
+all: $(OBJS) FORCE
+ ar rv $(LIBRARY) $(OBJS)
+ $(RANLIB) $(LIBRARY)
+
+cdTimeConv.o: cdTimeConv.c ../../include/cdmsint.h ../../include/cdms.h ../../include/cdunif.h
+fcdTimeConv.o: fcdTimeConv.c ../../include/cdmsint.h ../../include/cdms.h ../../include/cdunif.h ../../include/cfortran.h
+timeConv.o: timeConv.c ../../include/cdmsint.h ../../include/cdms.h ../../include/cdunif.h
+timeArith.o: timeArith.c ../../include/cdmsint.h ../../include/cdms.h ../../include/cdunif.h
+reg_trfm.o: reg_trfm.c ../../include/isdb.h ../../include/gaussLats.h
+cdRegTrfm.o: cdRegTrfm.c ../../include/cdmsint.h ../../include/cdms.h ../../include/cdunif.h ../../include/isdb.h
+
+.SUFFIXES: .F
+
+.c.o:
+ $(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) -c $<
+
+.c:
+ $(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) -o $@ $< $(LDFLAGS)
+
+.F:
+ case $(OS) in \
+ 'aix') \
+ /usr/ccs/lib/cpp -P $(CPPFLAGS) $(CFLAGS) $(INCLUDES) $(DEFS) $< $@.f; \
+ $(FC) $(FFLAGS) $(LDFLAGS) $(LIBS) $@.f -o $@; \
+ rm $@.f; \
+ ;; \
+ *) \
+ $(FC) $(CPPFLAGS) $(INCLUDES) $(DEFS) $(FFLAGS) -o $@ $< $(LDFLAGS) $(LIBS); \
+ ;; \
+ esac
+
+clean:
+ -rm -f *.o core *.~*~
+
+distclean: clean
+
+FORCE:
diff --git a/Src/cdTime/cdRegTrfm.c b/Src/cdTime/cdRegTrfm.c
new file mode 100644
index 0000000..cd88441
--- /dev/null
+++ b/Src/cdTime/cdRegTrfm.c
@@ -0,0 +1,139 @@
+/* -*-Mode: C;-*-
+ * Module: index <-> x-y <-> latlon wrapper routines
+ * CdXyIndex - x-y -> index
+ * CdIndexXy - index -> x-y
+ * CdLatLonXy - latlon -> x-y
+ * CdXyLatLon - x-y -> latlon
+ * CdIndexLatLon - index -> latlon
+ * CdLatLonIndex - latlon -> index
+ * CdMapGeom - map CDMS geom/order to NEONS geom
+ *
+ * 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$
+ *
+ * Revision History:
+ *
+ * $Log: cdRegTrfm.c,v $
+ * Revision 1.2 1996/02/21 23:56:46 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
+ *
+ * Revision 1.1 1994/08/12 19:03:53 drach
+ * Entered into CVS
+ *
+ *
+ */
+
+#include <stdio.h>
+#include <cdmsint.h>
+#include <isdb.h>
+ /* copy CDMS geom to NEONS ngeom */
+void
+CdCopyGeom(CdRegGeom *geom, REG_GEOM *ngeom)
+{
+ strncpy(ngeom->prjn_name,geom->prjnName,21);
+ ngeom->nx = geom->nx;
+ ngeom->ny = geom->ny;
+ ngeom->lat = geom->lat;
+ ngeom->lon = geom->lon;
+ ngeom->orig_ix = geom->orig_ix;
+ ngeom->orig_iy = geom->orig_iy;
+ ngeom->x_int_dis = geom->x_int_dis;
+ ngeom->y_int_dis = geom->y_int_dis;
+ ngeom->parm_1 = geom->parm_1;
+ ngeom->parm_2 = geom->parm_2;
+ ngeom->parm_3 = geom->parm_3;
+
+ return;
+}
+
+ /* Copy CDMS geom & order to NEONS ngeom */
+void
+CdMapGeom(CdRegGeom *geom, CdOrder *order, REG_GEOM *ngeom)
+{
+ if(order->lonDir < 0){
+ fprintf(stderr,"CDMS error: longitude direction must be non-negative.\n");
+ }
+
+ if(order->lonDir < order->latDir)
+ if(order->latDir > 0)
+ strcpy(ngeom->stor_dsc,"+x in +y");
+ else
+ strcpy(ngeom->stor_dsc,"+x in -y");
+ else
+ if(order->latDir > 0)
+ strcpy(ngeom->stor_dsc,"+y in +x");
+ else
+ strcpy(ngeom->stor_dsc,"-y in +x");
+
+ CdCopyGeom(geom,ngeom);
+ return;
+}
+
+int
+CdXyIndex(CdRegGeom *geom, CdOrder *order, long ix, long iy, long *index)
+{
+ REG_GEOM ngeom;
+ int status;
+
+ CdMapGeom(geom,order,&ngeom);
+ xy_index(&ngeom,&ix,&iy,index,&status);
+ return (status == 0 ? 0 : 1);
+}
+int
+CdIndexXy(CdRegGeom *geom, CdOrder *order, long index, long *ix, long *iy)
+{
+ REG_GEOM ngeom;
+ int status;
+
+ CdMapGeom(geom,order,&ngeom);
+ index_xy(&ngeom,&index,ix,iy,&status);
+ return (status == 0 ? 0 : 1);
+}
+int
+CdLatLonXy(CdRegGeom *geom, double lat, double lon, double *x, double *y)
+{
+ REG_GEOM ngeom;
+ int status;
+
+ CdCopyGeom(geom,&ngeom); /* order is unused */
+ latlon_xy(&ngeom,&lat,&lon,x,y,&status);
+ return (status == 0 ? 0 : 1);
+}
+int
+CdXyLatLon(CdRegGeom *geom, double x, double y, double *lat, double *lon)
+{
+ REG_GEOM ngeom;
+ int status;
+
+ CdCopyGeom(geom,&ngeom); /* order is unused */
+ xy_latlon(&ngeom,&x,&y,lat,lon,&status);
+ return (status == 0 ? 0 : 1);
+}
+int
+CdIndexLatLon(CdRegGeom *geom, CdOrder *order, long index, double *lat, double *lon)
+{
+ REG_GEOM ngeom;
+ int status;
+
+ CdMapGeom(geom,order,&ngeom);
+ index_latlon(&ngeom,&index,lat,lon,&status);
+ return (status == 0 ? 0 : 1);
+}
+int
+CdLatLonIndex(CdRegGeom *geom, CdOrder *order, double lat, double lon, long *index)
+{
+ REG_GEOM ngeom;
+ int status;
+
+ CdMapGeom(geom,order,&ngeom);
+ latlon_index(&ngeom,&lat,&lon,index,&status);
+ return (status == 0 ? 0 : 1);
+}
diff --git a/Src/cdTime/cdTimeConv.c b/Src/cdTime/cdTimeConv.c
new file mode 100644
index 0000000..3a557b4
--- /dev/null
+++ b/Src/cdTime/cdTimeConv.c
@@ -0,0 +1,1110 @@
+/* -*-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$
+ *
+ * Revision History:
+ *
+ * $Log: cdTimeConv.c,v $
+ * 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 <string.h>
+#include <ctype.h>
+#include <math.h>
+#include "cdmsint.h"
+
+void cdComp2RelMixed(cdCompTime ct, cdUnitTime unit, cdCompTime basetime, double *reltime);
+void cdRel2CompMixed(double reltime, cdUnitTime unit, cdCompTime basetime, cdCompTime *comptime);
+extern void
+CdDivDelTime(double begEtm, double endEtm, CdDeltaTime delTime, CdTimeType timeType,
+ long baseYear, long *nDel);
+extern void
+CdAddDelTime(double begEtm, long nDel, CdDeltaTime delTime, CdTimeType timeType,
+ long baseYear, double *endEtm);
+
+#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];
+/* double factor; */
+/* CdTime humantime; */
+ int nconv;
+/* CdTimeType old_timetype; */
+ /* 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 hour, sec; */
+ 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=0.;
+ 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;
+ case cdFraction:
+ 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;
+ case cdFraction:
+ 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;
+ case cdFraction:
+ 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, hour_fraction; */
+ double delta=0.;
+ long idelta=0;
+
+ /* 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;
+ case cdFraction:
+ 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;
+ case cdFraction:
+ 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 i, iform; */
+ 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;
+ case cdWeek: case cdSeason:
+ 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, fraction; */
+ 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;
+ case cdWeek: case cdSeason:
+ 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; */
+ double result=0.; /*initialize to get rid of warning */
+
+ 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;
+ case cdMonth: case cdSeason: case cdYear: case cdFraction:
+ break;
+ }
+ return result;
+}
+ /* Value is in hours. Translate to units. */
+double cdFromHours(double value, cdUnitTime unit){
+/* double result; */
+ double result=0.; /*initialize to get rid of warning */
+
+ 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;
+ case cdMonth: case cdSeason: case cdYear: case cdFraction:
+ 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/cdTime/cdUtil.c b/Src/cdTime/cdUtil.c
new file mode 100644
index 0000000..903309a
--- /dev/null
+++ b/Src/cdTime/cdUtil.c
@@ -0,0 +1,46 @@
+/* -*-Mode: C;-*-
+ * Module: CDMS utility functions
+ *
+ * Copyright: 1996, 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$
+ *
+ * Revision History:
+ *
+ * $Log: cdUtil.c,v $
+ * Revision 1.1.1.1 1997/12/09 18:57:40 drach
+ * Copied from cirrus
+ *
+ * Revision 1.1 1997/10/24 18:28:26 drach
+ * - Initial repository version
+ *
+ *
+ */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "cdmsint.h"
+
+int cuErrorOccurred = 0;
+void cdError(char *fmt, ...){
+ va_list args;
+
+ cuErrorOccurred = 1;
+ if(cuErrOpts & CU_VERBOSE){
+ va_start(args,fmt);
+ fprintf(stderr, "CDMS error: ");
+ vfprintf(stderr, fmt, args);
+ fprintf(stderr, "\n");
+ va_end(args);
+ }
+ if(cuErrOpts & CU_FATAL)
+ exit(1);
+ return;
+}
+
diff --git a/Src/cdTime/fcdTimeConv.c b/Src/cdTime/fcdTimeConv.c
new file mode 100644
index 0000000..9337a96
--- /dev/null
+++ b/Src/cdTime/fcdTimeConv.c
@@ -0,0 +1,118 @@
+/* -*-Mode: C;-*-
+ * Module: CDMS Fortran time conversion and arithmetic routines
+ *
+ * Copyright: 1996, 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$
+ *
+ * Revision History:
+ *
+ * $Log: fcdTimeConv.c,v $
+ * Revision 1.2 1996/09/09 18:28:34 drach
+ * - Cleaned up minor compilation warnings
+ *
+ * Revision 1.1 1996/04/04 19:02:28 drach
+ * - Initial version
+ *
+ *
+ */
+
+#include "cdmsint.h"
+#include "cfortran.h"
+
+/* Map C comptime struct to Fortran args
+ */
+
+#ifdef CRAY
+void cdfChar2Comp(int timetype, char* chartime, int* year, int* month, int* day, float* hour){
+#else
+void cdfChar2Comp(int timetype, char* chartime, int* year, int* month, int* day, double* hour){
+#endif
+ cdCompTime comptime;
+
+ cdChar2Comp(timetype, chartime, &comptime);
+ *year = comptime.year;
+ *month = comptime.month;
+ *day = comptime.day;
+ *hour = comptime.hour;
+
+ return;
+}
+
+#ifdef CRAY
+void cdfComp2Char(int timetype, int year, int month, int day, float hour, char* time){
+#else
+void cdfComp2Char(int timetype, int year, int month, int day, double hour, char* time){
+#endif
+ cdCompTime comptime;
+
+ comptime.year = year;
+ comptime.month = month;
+ comptime.day = day;
+ comptime.hour = hour;
+ cdComp2Char(timetype, comptime, time);
+
+ return;
+}
+
+#ifdef CRAY
+void cdfComp2Rel(int timetype, int year, int month, int day, double hour, char* relunits, float* reltime){
+ double dreltime;
+#else
+void cdfComp2Rel(int timetype, int year, int month, int day, double hour, char* relunits, double* reltime){
+#endif
+ cdCompTime comptime;
+
+ comptime.year = year;
+ comptime.month = month;
+ comptime.day = day;
+ comptime.hour = hour;
+#ifdef CRAY
+ cdComp2Rel(timetype, comptime, relunits, &dreltime);
+ *reltime=(float)dreltime;
+#else
+ cdComp2Rel(timetype, comptime, relunits, reltime);
+#endif
+
+ return;
+}
+
+#ifdef CRAY
+void cdfRel2Comp(int timetype, char* relunits, float reltime, int* year, int* month, int* day, double* hour){
+#else
+void cdfRel2Comp(int timetype, char* relunits, double reltime, int* year, int* month, int* day, double* hour){
+#endif
+ cdCompTime comptime;
+
+ cdRel2Comp(timetype, relunits, reltime, &comptime);
+
+ *year = comptime.year;
+ *month = comptime.month;
+ *day = comptime.day;
+ *hour = comptime.hour;
+
+ return;
+}
+
+#ifdef CRAY
+FCALLSCSUB6(cdfChar2Comp,FCDCHAR2COMP,fcdchar2comp,INT,STRING,PINT,PINT,PINT,PFLOAT)
+FCALLSCSUB4(cdChar2Rel,FCDCHAR2REL,fcdchar2rel,INT,STRING,STRING,PFLOAT)
+FCALLSCSUB6(cdfComp2Char,FCDCOMP2CHAR,fcdcomp2char,INT,INT,INT,INT,FLOAT,PSTRING)
+FCALLSCSUB7(cdfComp2Rel,FCDCOMP2REL,fcdcomp2rel,INT,INT,INT,INT,FLOAT,STRING,PFLOAT)
+FCALLSCSUB4(cdRel2Char,FCDREL2CHAR,fcdrel2char,INT,STRING,FLOAT,PSTRING)
+FCALLSCSUB7(cdfRel2Comp,FCDREL2COMP,fcdrel2comp,INT,STRING,FLOAT,PINT,PINT,PINT,PFLOAT)
+FCALLSCSUB5(cdRel2Rel,FCDREL2REL,fcdrel2rel,INT,STRING,FLOAT,STRING,PFLOAT)
+#else
+FCALLSCSUB6(cdfChar2Comp,FCDCHAR2COMP,fcdchar2comp,INT,STRING,PINT,PINT,PINT,PDOUBLE)
+FCALLSCSUB4(cdChar2Rel,FCDCHAR2REL,fcdchar2rel,INT,STRING,STRING,PDOUBLE)
+FCALLSCSUB6(cdfComp2Char,FCDCOMP2CHAR,fcdcomp2char,INT,INT,INT,INT,DOUBLE,PSTRING)
+FCALLSCSUB7(cdfComp2Rel,FCDCOMP2REL,fcdcomp2rel,INT,INT,INT,INT,DOUBLE,STRING,PDOUBLE)
+FCALLSCSUB4(cdRel2Char,FCDREL2CHAR,fcdrel2char,INT,STRING,DOUBLE,PSTRING)
+FCALLSCSUB7(cdfRel2Comp,FCDREL2COMP,fcdrel2comp,INT,STRING,DOUBLE,PINT,PINT,PINT,PDOUBLE)
+FCALLSCSUB5(cdRel2Rel,FCDREL2REL,fcdrel2rel,INT,STRING,DOUBLE,STRING,PDOUBLE)
+#endif
diff --git a/Src/cdTime/reg_trfm.c b/Src/cdTime/reg_trfm.c
new file mode 100644
index 0000000..e7a5cee
--- /dev/null
+++ b/Src/cdTime/reg_trfm.c
@@ -0,0 +1,962 @@
+
+/*
+ * set of routines to transform between x-y and lat-lon on registered grids
+ */
+#include <stdio.h>
+#include <math.h>
+#include <isdb.h>
+#include "gaussLats.h"
+
+#define LOGE10 2.302585093 /* natural log of 10 */
+#define ERTH_RAD 6371.229 /* mean earth radius (km) */
+#define PI180 0.017453293 /* pi / 180. */
+#define MIN_LAT -90.
+#define MAX_LAT 90.
+#define MIN_LON -180.
+#define MAX_LON 180.
+
+/***************************************************************/
+/*
+ * transform from x, y coordinates within a registered grid to the index
+ */
+void xy_index(geom, ix, iy, index, status)
+REG_GEOM *geom; /* registered geometry structure from isdb.h */
+long *ix; /* column number, left column is 1 */
+long *iy; /* row number, top row is 1 */
+long *index; /* index within grid */
+int *status; /* return status */
+{
+
+/* Check ix is within 1, nx */
+ if ((*ix < 1) || (*ix > geom->nx)) {
+ *status = -1;
+ return;
+ }
+
+/* Check iy is within 1, ny */
+ if ((*iy < 1) || (*iy > geom->ny)) {
+ *status = -1;
+ return;
+ }
+
+/* Compute index from ix, iy depending on storage order of points in grid */
+/* Next portion of code can be speeded up */
+ if (strcmp(geom->stor_dsc, "+x in -y") == 0) {
+ *index = (*iy - 1) * geom->nx + *ix;
+
+ } else if (strcmp(geom->stor_dsc, "+x in +y") == 0) {
+ *index = (geom->ny - *iy) * geom->nx + *ix;
+
+ } else if (strcmp(geom->stor_dsc, "-y in +x") == 0) {
+ *index = (*ix - 1) * geom->ny + *iy;
+
+ } else if (strcmp(geom->stor_dsc, "+y in +x") == 0) {
+ *index = (*ix - 1) * geom->ny + geom->ny - *iy + 1;
+
+ } else {
+ fprintf(stderr, "Error in xy_index; stor_dsc: %s not supported\n",
+ geom->stor_dsc);
+ *status = -1;
+ return;
+ }
+ *status = 0;
+ return;
+
+}
+
+/***************************************************************/
+/*
+ * transform from the index within a registered grid to x, y coordinates
+ */
+void index_xy(geom, index, ix, iy, status)
+REG_GEOM *geom; /* registered geometry structure from isdb.h */
+long *index; /* index within grid */
+long *ix; /* column number, left column is 1 */
+long *iy; /* row number, top row is 1 */
+int *status; /* return status */
+{
+
+/* Check index is within 1, nx*ny */
+ if ((*index < 1) || (*index > geom->nx * geom->ny)) {
+ fprintf(stderr, "Error in index_xy; index: %d nx*ny: %d\n",
+ *index, geom->nx * geom->ny);
+ *status = -1;
+ return;
+ }
+
+/* Compute ix, iy from index depending on storage order of points in grid */
+/* Next portion of code can be speeded up */
+ if (strcmp(geom->stor_dsc, "+x in -y") == 0) {
+ *iy = (*index + (geom->nx - 1)) / geom->nx;
+ *ix = *index - (*iy - 1) * geom->nx;
+
+ } else if (strcmp(geom->stor_dsc, "+x in +y") == 0) {
+ *iy = (geom->nx * geom->ny - *index + geom->nx) / geom->nx;
+ *ix = *index - (geom->ny - *iy) * geom->nx;
+
+ } else if (strcmp(geom->stor_dsc, "-y in +x") == 0) {
+ *ix = (*index - 1) / geom->ny + 1;
+ *iy = *index - (*ix - 1) * geom->ny;
+
+ } else if (strcmp(geom->stor_dsc, "+y in +x") == 0) {
+ *ix = (*index - 1) / geom->ny + 1;
+ *iy = *ix * geom->ny - *index + 1;
+
+ } else {
+ fprintf(stderr, "Error in index_xy; stor_dsc: %s not supported\n",
+ geom->stor_dsc);
+ *status = -1;
+ return;
+ }
+ *status = 0;
+ return;
+
+}
+
+/***************************************************************/
+/*
+ * transform from latitude and longitude to x, y coordinates within
+ * a registered grid
+ */
+void latlon_xy(geom, lat, lon, x, y, status)
+REG_GEOM *geom; /* registered geometry structure from isdb.h */
+double *lat; /* latitude in degrees */
+double *lon; /* longitude in degrees */
+double *x; /* x coord in units of columns, left col is 1 */
+double *y; /* y coord in units of rows, top row is 1 */
+int *status; /* return status */
+{
+ extern void CdLookup(double *, long, double, long *);
+ double temp1, temp2, temp3, temp4, temp5, *tempp; /* temporary variables */
+ double sign; /* temporary variable containing sign */
+ double diff_lon; /* longitude difference holder */
+ long len,k;
+
+/* Check if latitude is within limits */
+ if ((*lat < MIN_LAT) || (*lat > MAX_LAT)) {
+ fprintf(stderr, "Error in latlon_xy; lat: %lf not in %f, %f\n",
+ *lat, MIN_LAT, MAX_LAT);
+ *status = -1;
+ return;
+ }
+
+/* Check if longitude is within limits */
+ if ((*lon < MIN_LON) || (*lon > MAX_LON)) {
+ fprintf(stderr, "Error in latlon_xy; lon: %lf not in %f, %f\n",
+ *lon, MIN_LON, MAX_LON);
+ *status = -1;
+ return;
+ }
+
+/*
+ * Compute x, y from lat, lon depending on projection
+ */
+ if (strcmp(geom->prjn_name, "gaussian") == 0) {
+ diff_lon = *lon - geom->lon;
+ *x = diff_lon / geom->parm_2 + (double) geom->orig_ix;
+
+ /* Take care of longitude wrap-around */
+
+ if (*x < 0.) *x += (double) geom->nx;
+ if (*x > (double) geom->nx) *x -= (double) geom->nx;
+
+ switch (geom->ny){
+ case T21_LEN:
+ tempp = t21Lats;
+ len = T21_LEN;
+ break;
+ case R15_LEN:
+ tempp = r15Lats;
+ len = R15_LEN;
+ break;
+ case T32_LEN:
+ tempp = t32Lats;
+ len = T32_LEN;
+ break;
+ case R21_LEN:
+ tempp = r21Lats;
+ len = R21_LEN;
+ break;
+ case T42_LEN:
+ tempp = t42Lats;
+ len = T42_LEN;
+ break;
+ case R31_LEN:
+ tempp = r31Lats;
+ len = R31_LEN;
+ break;
+ case T63_LEN:
+ tempp = t63Lats;
+ len = T63_LEN;
+ break;
+ case R40_LEN:
+ tempp = r40Lats;
+ len = R40_LEN;
+ break;
+ case T106_LEN:
+ tempp = t106Lats;
+ len = T106_LEN;
+ break;
+ default:
+ fprintf(stderr, "Error in latlon_xy; no Gaussian latitude of length %d\n",
+ geom->ny);
+ *status = -1;
+ return;
+ };
+ /* Lookup latitude; vector include poles */
+ CdLookup(tempp,len+2,*lat,&k);
+ if(k == -1)
+ *y = 0.;
+ else if (k == (len+1))
+ *y = (double)(len+1);
+ else
+ *y = (double) k + (*lat - (*(tempp+k)))/((*(tempp+k+1)) - (*(tempp+k)));
+ }
+ /* Cylindrical equal-area, e.g., LMD grid */
+ /* Note: returns 0.5 <= y <= geom->ny+0.5 */
+ else if (strcmp(geom->prjn_name, "cylindrical_eq_area") == 0) {
+ diff_lon = *lon - geom->lon;
+ *x = diff_lon / geom->parm_2 + (double) geom->orig_ix;
+
+ /* Take care of longitude wrap-around */
+
+ if (*x < 0.) *x += (double) geom->nx;
+ if (*x > (double) geom->nx) *x -= (double) geom->nx;
+
+ *y = 0.5 * (geom->ny * (1.0 - sin(PI180*(*lat))) + 1.0);
+ }
+ else if (strcmp(geom->prjn_name, "spherical") == 0) {
+ diff_lon = *lon - geom->lon;
+ *x = diff_lon / geom->parm_2 + (double) geom->orig_ix;
+
+/* Take care of longitude wrap-around */
+ if ((*x < 1.) || (*x > (double) geom->nx)) {
+ temp1 = (diff_lon - 360.) / geom->parm_2 + (double) geom->orig_ix;
+ if (fabs((double)(geom->orig_ix + 1) / 2. - temp1) <
+ fabs((double)(geom->orig_ix + 1) / 2. - *x)) *x = temp1;
+ temp1 = (diff_lon + 360.) / geom->parm_2 + (double) geom->orig_ix;
+ if (fabs((double)(geom->orig_ix + 1) / 2. - temp1) <
+ fabs((double)(geom->orig_ix + 1) / 2. - *x)) *x = temp1;
+ }
+
+ *y = (geom->lat - *lat) / geom->parm_1 + (double) geom->orig_iy;
+
+ } else if (strcmp(geom->prjn_name, "mercator") == 0) {
+/* Mercator requires: 0 <= parm_1 < 90;
+ * other standard latitude = -parm_1
+ * top of grid always toward N */
+/* Check lat is not equal to 90. or -90. (singular points) */
+ if ((*lat == MIN_LAT) || (*lat == MAX_LAT)) {
+ fprintf(stderr, "Error in latlon_xy; lat: %f = %f or %f\n",
+ *lat, MIN_LAT, MAX_LAT);
+ *status = -1;
+ return;
+ }
+ diff_lon = *lon - geom->lon;
+ *x = diff_lon / geom->parm_2 + (double) geom->orig_ix;
+
+/* Take care of longitude wrap-around */
+ if ((*x < 1.) || (*x > (double) geom->nx)) {
+ temp1 = (diff_lon - 360.) / geom->parm_2 + (double) geom->orig_ix;
+ if (fabs((double)(geom->orig_ix + 1) / 2. - temp1) <
+ fabs((double)(geom->orig_ix + 1) / 2. - *x)) *x = temp1;
+ temp1 = (diff_lon + 360.) / geom->parm_2 + (double) geom->orig_ix;
+ if (fabs((double)(geom->orig_ix + 1) / 2. - temp1) <
+ fabs((double)(geom->orig_ix + 1) / 2. - *x)) *x = temp1;
+ }
+
+ temp1 = ERTH_RAD * cos((double) geom->parm_1 * PI180) /
+ geom->y_int_dis;
+ temp2 = (geom->lat + 90.) * PI180 / 2.;
+ temp3 = (double) geom->orig_iy + temp1 * LOGE10 * log10( tan(temp2) );
+ temp4 = (*lat + 90.) * PI180 / 2.;
+ *y = temp3 - temp1 * LOGE10 * log10( tan(temp4) );
+
+ } else if (strcmp(geom->prjn_name, "polar_stereo") == 0) {
+ sign = (geom->parm_1 > 0.) ? 1. : -1.;
+ temp1 = (*lon - (double) geom->parm_2) * PI180;
+ temp2 = tan((45. - sign * *lat / 2.) * PI180);
+ temp3 = ERTH_RAD * (1. + sin(fabs((double) geom->parm_1) * PI180));
+ temp4 = (geom->lon - (double) geom->parm_2) * PI180;
+ temp5 = tan((45. - sign * geom->lat / 2.) * PI180);
+ *x = (double) geom->orig_ix - temp3 / geom->x_int_dis *
+ (temp5 * sin(temp4) - temp2 * sin(temp1));
+ *y = (double) geom->orig_iy - sign * temp3 / geom->y_int_dis *
+ (temp5 * cos(temp4) - temp2 * cos(temp1));
+
+ } else if (strcmp(geom->prjn_name, "lambert") == 0) {
+/* Lambert requires: 0 < |parm_1,2| < 90
+ * |parm_1| <= |parm_2|
+ * parm_1 * parm_2 > 0
+ * top of grid always toward N */
+/* Check lat is not equal to 90. or -90. (singular points) */
+ if ((*lat == MIN_LAT) || (*lat == MAX_LAT)) {
+ fprintf(stderr, "Error in latlon_xy; lat: %f = %f or %f\n",
+ *lat, MIN_LAT, MAX_LAT);
+ *status = -1;
+ return;
+ }
+ sign = (geom->parm_1 > 0.) ? 1. : -1.;
+ if (geom->parm_1 == geom->parm_2) {
+ temp1 = sign * sin(geom->parm_1 * PI180);
+ } else {
+ temp1 = log(cos(geom->parm_1 * PI180) /
+ cos(geom->parm_2 * PI180)) /
+ log(tan((45. + sign * geom->parm_2 / 2.) * PI180) /
+ tan((45. + sign * geom->parm_1 / 2.) * PI180));
+ }
+
+/* Take care of longitude wrap-around for (*lon - geom->parm_3) */
+ diff_lon = *lon - geom->parm_3;
+ if (fabs(*lon - geom->parm_3 - 360.) < fabs(diff_lon))
+ diff_lon = *lon - geom->parm_3 - 360.;
+ if (fabs(*lon - geom->parm_3 + 360.) < fabs(diff_lon))
+ diff_lon = *lon - geom->parm_3 + 360.;
+
+/* Take care of longitude wrap-around for (geom->lon - geom->parm_3) */
+ temp5 = geom->lon - geom->parm_3;
+ if (fabs(geom->lon - geom->parm_3 - 360.) < fabs(temp5))
+ temp5 = geom->lon - geom->parm_3 - 360.;
+ if (fabs(geom->lon - geom->parm_3 + 360.) < fabs(temp5))
+ temp5 = geom->lon - geom->parm_3 + 360.;
+
+ temp2 = cos(geom->parm_1 * PI180) * ERTH_RAD / temp1 *
+ pow(tan((45. + sign * geom->parm_1 / 2.) * PI180), temp1);
+ temp3 = pow(tan((45. + sign * geom->lat / 2.) * PI180), temp1);
+ temp4 = pow(tan((45. + sign * *lat / 2.) * PI180), temp1);
+ *x = (double) geom->orig_ix - temp2 / geom->x_int_dis *
+ (sin(temp1 * temp5 * PI180) / temp3 -
+ sin(temp1 * diff_lon * PI180) / temp4);
+ *y = (double) geom->orig_iy - temp2 / geom->y_int_dis * sign *
+ (cos(temp1 * temp5 * PI180) / temp3 -
+ cos(temp1 * diff_lon * PI180) / temp4);
+
+ } else {
+ fprintf(stderr, "Error in latlon_xy; prjn_name: %s not supported\n",
+ geom->prjn_name);
+ *status = -1;
+ return;
+ }
+/*
+ printf("ll_xy; lat: %f lon: %f x: %lf y: %lf\n", *lat, *lon, *x, *y);
+ */
+ *status = 0;
+ return;
+}
+
+/***************************************************************/
+/*
+ * transform from x, y coordinates within a registered grid to
+ * latitude and longitude
+ */
+void xy_latlon(geom, x, y, lat, lon, status)
+REG_GEOM *geom; /* registered geometry structure from isdb.h */
+double *x; /* x coord in units of columns, left col is 1 */
+double *y; /* y coord in units of rows, top row is 1 */
+double *lat; /* latitude in degrees */
+double *lon; /* longitude in degrees */
+int *status;
+{
+ double temp1, temp2, temp3, temp4, temp5, *tempp; /* temporary variables */
+ double sign; /* temporary variable containing sign */
+ long i;
+
+/* Check if x is within 0, nx + 1 */
+ if ((*x < 0.) || (*x > (double) geom->nx + 1.)) {
+ fprintf(stderr, "Error in xy_latlon; x: %lf not in 0, %d\n",
+ *x, geom->nx + 1);
+ *status = -1;
+ return;
+ }
+
+/* Check if y is within 0, ny + 1 */
+ if ((*y < 0.) || (*y > (double) geom->ny + 1.)) {
+ fprintf(stderr, "Error in xy_latlon; y: %lf not in 0, %d\n",
+ *y, geom->ny + 1);
+ *status = -1;
+ return;
+ }
+
+/*
+ * Compute lat, lon from x, y depending on projection
+ */
+
+ if (strcmp(geom->prjn_name, "gaussian") == 0) {
+ *lon = (*x - (double) geom->orig_ix) * geom->parm_2 + geom->lon;
+ i = *y;
+ temp1 = *y - (double)i;
+ switch (geom->ny){
+ case T21_LEN:
+ tempp = t21Lats+i;
+ break;
+ case R15_LEN:
+ tempp = r15Lats+i;
+ break;
+ case T32_LEN:
+ tempp = t32Lats+i;
+ break;
+ case R21_LEN:
+ tempp = r21Lats+i;
+ break;
+ case T42_LEN:
+ tempp = t42Lats+i;
+ break;
+ case R31_LEN:
+ tempp = r31Lats+i;
+ break;
+ case T63_LEN:
+ tempp = t63Lats+i;
+ break;
+ case R40_LEN:
+ tempp = r40Lats+i;
+ break;
+ case T106_LEN:
+ tempp = t106Lats+i;
+ break;
+ default:
+ fprintf(stderr, "Error in xy_latlon; no Gaussian latitude of length %d\n",
+ geom->ny);
+ *status = -1;
+ return;
+ };
+ if (i == geom->ny + 1)
+ *lat = *tempp;
+ else
+ *lat = temp1*(*(tempp+1)) + (1.-temp1)*(*tempp);
+ }
+ /* Cylindrical equal-area, e.g., LMD grid */
+ else if (strcmp(geom->prjn_name, "cylindrical_eq_area") == 0) {
+
+ /* Must have 0.5 <= y <= ny+0.5*/
+ if ((*y < 0.5) || (*y > (double) geom->ny + 0.5)) {
+ fprintf(stderr, "Error in xy_latlon; y: %lf not in 0.5, %lf\n",
+ *y, (double) geom->ny + 0.5);
+ *status = -1;
+ return;
+ }
+
+ *lon = (*x - (double) geom->orig_ix) * geom->parm_2 + geom->lon;
+
+ *lat = asin(1.0 - (2.0*(*y) - 1.0)/(double)geom->ny)/PI180;
+
+ }
+ else if (strcmp(geom->prjn_name, "spherical") == 0) {
+ *lon = (*x - (double) geom->orig_ix) * geom->parm_2 + geom->lon;
+ *lat = ((double) geom->orig_iy - *y) * geom->parm_1 + geom->lat;
+
+ } else if (strcmp(geom->prjn_name, "mercator") == 0) {
+/* Mercator requires: 0 <= parm_1 < 90;
+ * other standard latitude = -parm_1
+ * top of grid always toward N */
+ *lon = (*x - (double) geom->orig_ix) * geom->parm_2 + geom->lon;
+ temp1 = ERTH_RAD * cos((double) geom->parm_1 * PI180) /
+ geom->y_int_dis;
+ temp2 = (geom->lat + 90.) * PI180 / 2.;
+ temp3 = (double) geom->orig_iy + temp1 *
+ LOGE10 * log10( tan(temp2) );
+ *lat = 2. / PI180 * atan( exp((temp3 - *y) / temp1) ) - 90.;
+
+ } else if (strcmp(geom->prjn_name, "polar_stereo") == 0) {
+ sign = (geom->parm_1 > 0.) ? 1. : -1.;
+ temp1 = (geom->lon - (double) geom->parm_2) * PI180;
+ temp2 = tan((45. - sign * geom->lat / 2.) * PI180);
+ temp3 = ERTH_RAD * (1. + sin(fabs((double) geom->parm_1) * PI180));
+ temp4 = (*x - (double) geom->orig_ix) * geom->x_int_dis /
+ temp3 + temp2 * sin(temp1);
+ temp5 = sign * (*y - (double) geom->orig_iy) * geom->y_int_dis /
+ temp3 + temp2 * cos(temp1);
+ *lon = 1. / PI180 * atan2(temp4, temp5) + (double) geom->parm_2;
+ if (fabs(cos((double) (*lon - geom->parm_2) * PI180)) > .7071) {
+ *lat = sign * (90. - 2. / PI180 * atan(temp5 /
+ cos((double) (*lon - geom->parm_2) * PI180)));
+ } else { /* use sine if cosine approaches 0. */
+ *lat = sign * (90. - 2. / PI180 * atan(temp4 /
+ sin((double) (*lon - geom->parm_2) * PI180)));
+ }
+
+ } else if (strcmp(geom->prjn_name, "lambert") == 0) {
+/* Lambert requires: 0 < |parm_1,2| < 90
+ * |parm_1| <= |parm_2|
+ * parm_1 * parm_2 > 0
+ * top of grid always toward N */
+ sign = (geom->parm_1 > 0.) ? 1. : -1.;
+ if (geom->parm_1 == geom->parm_2) {
+ temp1 = sign * sin(geom->parm_1 * PI180);
+ } else {
+ temp1 = log(cos(geom->parm_1 * PI180) /
+ cos(geom->parm_2 * PI180)) /
+ log(tan((45. + sign * geom->parm_2 / 2.) * PI180) /
+ tan((45. + sign * geom->parm_1 / 2.) * PI180));
+ }
+ temp2 = cos(geom->parm_1 * PI180) / temp1 *
+ pow(tan((45. + sign * geom->parm_1 / 2.) * PI180), temp1);
+ temp3 = pow(tan((45. + sign * geom->lat / 2.) * PI180), temp1);
+ *lon = geom->parm_3 + 1. / PI180 / temp1 * atan2(
+ ((*x - (double) geom->orig_ix) * geom->x_int_dis / ERTH_RAD +
+ sin(temp1 * (geom->lon - geom->parm_3) * PI180) * temp2 /
+ temp3), ((*y - (double) geom->orig_iy) * geom->y_int_dis /
+ ERTH_RAD * sign + cos(temp1 * (geom->lon - geom->parm_3) *
+ PI180) * temp2 / temp3));
+ *lat = sign * (-90. + 2. / PI180 * atan(
+ pow((temp2 * cos(temp1 * (*lon - geom->parm_3) * PI180)) /
+ ((*y - (double) geom->orig_iy) * geom->y_int_dis / ERTH_RAD *
+ sign + cos(temp1 * (geom->lon - geom->parm_3) * PI180) *
+ temp2 / temp3), 1. / temp1)));
+
+ } else {
+ fprintf(stderr, "Error in xy_latlon; prjn_name: %s not supported\n",
+ geom->prjn_name);
+ *status = -1;
+ return;
+ }
+
+/* Take care of longitude wrap-around */
+ if (*lon < MIN_LON) *lon += 360.;
+ if (*lon > MAX_LON) *lon -= 360.;
+/*
+ printf("xy_ll; lat: %f lon: %f x: %lf y: %lf\n", *lat, *lon, *x, *y);
+ */
+ *status = 0;
+ return;
+}
+
+/***************************************************************/
+/*
+ * transform from the index within a registered grid to latitude and longitude
+ */
+void index_latlon(geom, index, lat, lon, status)
+REG_GEOM *geom; /* registered geometry structure from isdb.h */
+long *index; /* index within grid */
+double *lat; /* latitude in degrees */
+double *lon; /* longitude in degrees */
+int *status;
+{
+ double x; /* x coord in units of columns, left col is 1 */
+ double y; /* y coord in units of rows, top row is 1 */
+ long ix; /* column number, left column is 1 */
+ long iy; /* row number, top row is 1 */
+ extern void index_xy(), xy_latlon();
+
+/* Convert from index to ix, iy */
+ index_xy(geom, index, &ix, &iy, status);
+ if (*status < 0) {
+ return;
+ }
+
+/*
+ fprintf(stderr, "\n index_latlon ix: %d iy: %d\n", ix, iy);
+*/
+ x = (double) ix;
+ y = (double) iy;
+
+/* Convert from x, y to lat, lon */
+ xy_latlon(geom, &x, &y, lat, lon, status);
+ if (*status < 0) {
+ return;
+ }
+
+ *status = 0;
+ return;
+}
+
+/***************************************************************/
+/*
+ * transform from latitude and longitude to the index within a registered grid
+ * (find the closest grid point to some lat, lon)
+ */
+void latlon_index(geom, lat, lon, index, status)
+REG_GEOM *geom; /* registered geometry structure from isdb.h */
+double *lat; /* latitude in degrees */
+double *lon; /* longitude in degrees */
+long *index; /* index within grid */
+int *status; /* return status */
+{
+ double x; /* x coord in units of columns, left col is 1 */
+ double y; /* y coord in units of rows, top row is 1 */
+ long ix; /* column number, left column is 1 */
+ long iy; /* row number, top row is 1 */
+ extern void latlon_xy(), xy_index();
+
+
+/* Convert from lat, lon to x, y */
+ latlon_xy(geom, lat, lon, &x, &y, status);
+ if (*status < 0) {
+ return;
+ }
+
+/* Round to nearest grid point */
+ ix = (long) (x + .5);
+ iy = (long) (y + .5);
+/*
+ fprintf(stderr, "latlon_index ix: %d iy: %d\n", ix, iy);
+*/
+
+/* Convert from ix, iy to index */
+ xy_index(geom, &ix, &iy, index, status);
+ if (*status < 0) {
+ return;
+ }
+
+ *status = 0;
+ return;
+}
+
+/***************************************************************/
+/*
+ * get the (float) value from a registered grid at some latitude
+ * and longitude (interpolate from 4 nearest grid points)
+ */
+void getf_latlon(geom, lat, lon, fbuff, fpixel, status)
+REG_GEOM *geom; /* registered geometry structure from isdb.h */
+double *lat; /* latitude in degrees */
+double *lon; /* longitude in degrees */
+float *fbuff; /* array containing values at all grid points */
+float *fpixel; /* value at lat, lon */
+int *status; /* return status */
+{
+ long index; /* index within grid */
+ long ix, ix1; /* column number, left column is 1 */
+ long iy, iy1; /* row number, top row is 1 */
+ double x; /* x coord in units of columns, left col is 1 */
+ double y; /* y coord in units of rows, top row is 1 */
+ extern void latlon_xy(), xy_index();
+
+ *fpixel = 0.;
+
+/* Convert from lat, lon to x, y */
+ latlon_xy(geom, lat, lon, &x, &y, status);
+ if (*status < 0) {
+ return;
+ }
+/*
+fprintf(stdout, "lat: %f lon: %f x: %lf y: %lf\n", *lat, *lon, x, y);
+ */
+
+/* Find nearest 4 points */
+ ix = (long) x;
+ ix1 = ix + 1;
+ iy = (long) y;
+ iy1 = iy + 1;
+
+/* Check point ix,iy lies inside grid */
+ if ((ix1 < 1) || (ix > geom->nx)) {
+ *status = -1;
+ return;
+ }
+ if ((iy1 < 1) || (iy > geom->ny)) {
+ *status = -1;
+ return;
+ }
+
+/* Do point (ix+1, iy+1) */
+ xy_index(geom, &ix1, &iy1, &index, status);
+ if (*status == 0) {
+ *fpixel += *(fbuff + index-1) *
+ (x - (double) ix) * (y - (double) iy);
+ }
+
+/* Do point (ix+1, iy) */
+ xy_index(geom, &ix1, &iy, &index, status);
+ if (*status == 0) {
+ *fpixel += *(fbuff + index-1) *
+ (x - (double) ix) * ((double) iy1 - y);
+ }
+
+/* Do point (ix, iy+1) */
+ xy_index(geom, &ix, &iy1, &index, status);
+ if (*status == 0) {
+ *fpixel += *(fbuff + index-1) *
+ ((double) ix1 - x) * (y - (double) iy);
+ }
+
+/* Do point (ix, iy) */
+ xy_index(geom, &ix, &iy, &index, status);
+ if (*status == 0) {
+ *fpixel += *(fbuff + index-1) *
+ ((double) ix1 - x) * ((double) iy1 - y);
+ }
+
+ *status = 0;
+ return;
+}
+
+/***************************************************************/
+/*
+ * put the (float) value onto a registered grid at some latitude
+ * and longitude (smear over 4 nearest grid points)
+ */
+void putf_latlon(geom, lat, lon, fpixel, fbuff, status)
+REG_GEOM *geom; /* registered geometry structure from isdb.h */
+double *lat; /* latitude in degrees */
+double *lon; /* longitude in degrees */
+float *fpixel; /* value at lat, lon */
+float *fbuff; /* array containing values at all grid points */
+int *status; /* return status */
+{
+ long index; /* index within grid */
+ long ix, ix1; /* column number, left column is 1 */
+ long iy, iy1; /* row number, top row is 1 */
+ double x; /* x coord in units of columns, left col is 1 */
+ double y; /* y coord in units of rows, top row is 1 */
+ extern void latlon_xy(), xy_index();
+
+/* Convert from lat, lon to x, y */
+ latlon_xy(geom, lat, lon, &x, &y, status);
+ if (*status < 0) {
+ return;
+ }
+/*
+fprintf(stdout, "lat: %f lon: %f x: %lf y: %lf\n", *lat, *lon, x, y);
+ */
+
+/* Find nearest 4 points */
+ ix = (long) x;
+ ix1 = ix + 1;
+ iy = (long) y;
+ iy1 = iy + 1;
+
+/* Check point ix,iy lies inside grid */
+ if ((ix1 < 1) || (ix > geom->nx)) {
+ *status = -1;
+ return;
+ }
+ if ((iy1 < 1) || (iy > geom->ny)) {
+ *status = -1;
+ return;
+ }
+
+/* Do point (ix+1, iy+1) */
+ xy_index(geom, &ix1, &iy1, &index, status);
+ if (*status == 0) {
+ *(fbuff + index-1) = *fpixel *
+ (x - (double) ix) * (y - (double) iy);
+ }
+
+/* Do point (ix+1, iy) */
+ xy_index(geom, &ix1, &iy, &index, status);
+ if (*status == 0) {
+ *(fbuff + index-1) = *fpixel *
+ (x - (double) ix) * ((double) iy1 - y);
+ }
+
+/* Do point (ix, iy+1) */
+ xy_index(geom, &ix, &iy1, &index, status);
+ if (*status == 0) {
+ *(fbuff + index-1) = *fpixel *
+ ((double) ix1 - x) * (y - (double) iy);
+ }
+
+/* Do point (ix, iy) */
+ xy_index(geom, &ix, &iy, &index, status);
+ if (*status == 0) {
+ *(fbuff + index-1) = *fpixel *
+ ((double) ix1 - x) * ((double) iy1 - y);
+ }
+
+ *status = 0;
+ return;
+}
+
+
+/***************************************************************/
+/*
+ * compute the grid interval distance for a registered grid using a
+ * previously-located grid point
+ */
+void get_int_dis(geom, x, y, lat, lon, status)
+REG_GEOM *geom; /* registered geometry structure from isdb.h */
+double *x; /* x coord of known point in units of columns */
+double *y; /* y coord of known point in units of rows */
+double *lat; /* latitude of known point in degrees */
+double *lon; /* longitude of known point in degrees */
+int *status; /* return status */
+{
+ double temp1, temp2, temp3, temp4, temp5; /* temporary variables */
+ double sign; /* temporary variable containing sign */
+
+/* Check lat is within limits */
+ if ((*lat < MIN_LAT) || (*lat > MAX_LAT)) {
+ fprintf(stderr, "Error in get_int_dis; lat: %lf not in %f, %f\n",
+ *lat, MIN_LAT, MAX_LAT);
+ *status = -1;
+ return;
+ }
+
+/* Check lon is within limits */
+ if ((*lon < MIN_LON) || (*lon > MAX_LON)) {
+ fprintf(stderr, "Error in get_int_dis; lon: %lf not in %f, %f\n",
+ *lon, MIN_LON, MAX_LON);
+ *status = -1;
+ return;
+ }
+
+/* Check y value different from y of origin */
+ if (fabs(*y - (double) geom->orig_iy) < 1.e-5) {
+ fprintf(stderr, "Error in get_int_dis; y: %f equals orig_iy: %d\n",
+ *y, geom->orig_iy);
+ *status = -1;
+ return;
+ }
+
+/* Check x value different from x of origin */
+ if (fabs(*x - (double) geom->orig_ix) < 1.e-5) {
+ fprintf(stderr, "Error in get_int_dis; x: %f equals orig_ix: %d\n",
+ *x, geom->orig_ix);
+ *status = -1;
+ return;
+ }
+
+/*
+ * Compute y_int_dis, x_int_dis from rest of geom info and x, y, lat, lon
+ */
+ if (strcmp(geom->prjn_name, "spherical") == 0) {
+ geom->y_int_dis = ERTH_RAD * PI180 * geom->parm_1;
+ geom->x_int_dis = ERTH_RAD * PI180 * geom->parm_2;
+
+ } else if (strcmp(geom->prjn_name, "mercator") == 0) {
+/* Mercator requires: 0 <= parm_1 < 90;
+ * other standard latitude = -parm_1
+ * top of grid always toward N */
+ temp1 = ERTH_RAD * cos((double) geom->parm_1 * PI180);
+ temp2 = PI180 / 2. * (geom->lat + 90.);
+ temp3 = PI180 / 2. * (*lat + 90.);
+ geom->y_int_dis = temp1 / (*y - (double) geom->orig_iy) *
+ LOGE10 * ( log10(tan(temp2)) - log10(tan(temp3)) );
+ geom->x_int_dis = geom->y_int_dis;
+
+ } else if (strcmp(geom->prjn_name, "polar_stereo") == 0) {
+ sign = (geom->lat > 0.) ? 1. : -1.;
+ temp1 = (*lon - (double) geom->parm_2) * PI180;
+ temp2 = tan((45. - sign * *lat / 2.) * PI180);
+ temp3 = ERTH_RAD * (1. + sin(fabs((double) geom->parm_1) * PI180));
+ temp4 = (geom->lon - (double) geom->parm_2) * PI180;
+ temp5 = tan((45. - sign * geom->lat / 2.) * PI180);
+ geom->y_int_dis = 1. / ((double) geom->orig_iy - *y) *
+ sign * temp3 * (temp5 * cos(temp4) - temp2 * cos(temp1));
+ geom->x_int_dis = 1. / ((double) geom->orig_ix - *x) *
+ temp3 * (temp5 * sin(temp4) - temp2 * sin(temp1));
+
+ } else if (strcmp(geom->prjn_name, "lambert") == 0) {
+/* Lambert requires: 0 < |parm_1,2| < 90
+ * |parm_1| <= |parm_2|
+ * parm_1 * parm_2 > 0
+ * top of grid always toward N */
+ sign = (geom->parm_1 > 0.) ? 1. : -1.;
+ if (geom->parm_1 == geom->parm_2) {
+ temp1 = sign * sin(geom->parm_1 * PI180);
+ } else {
+ temp1 = log(cos(geom->parm_1 * PI180) /
+ cos(geom->parm_2 * PI180)) /
+ log(tan((45. + sign * geom->parm_2 / 2.) * PI180) /
+ tan((45. + sign * geom->parm_1 / 2.) * PI180));
+ }
+ temp2 = cos(geom->parm_1 * PI180) * ERTH_RAD / temp1 *
+ pow(tan((45. + sign * geom->parm_1 / 2.) * PI180), temp1);
+ temp3 = pow(tan((45. + sign * geom->lat / 2.) * PI180), temp1);
+ temp4 = pow(tan((45. + sign * *lat / 2.) * PI180), temp1);
+ geom->x_int_dis = temp2 / ((double) geom->orig_ix - *x) *
+ (sin(temp1 * (geom->lon - geom->parm_3) * PI180) / temp3 -
+ sin(temp1 * (*lon - geom->parm_3) * PI180) / temp4);
+ geom->y_int_dis = temp2 / ((double) geom->orig_iy - *y) * sign *
+ (cos(temp1 * (geom->lon - geom->parm_3) * PI180) / temp3 -
+ cos(temp1 * (*lon - geom->parm_3) * PI180) / temp4);
+
+ } else {
+ fprintf(stderr, "Error in get_int_dis; prjn_name: %s not supported\n",
+ geom->prjn_name);
+ *status = -1;
+ return;
+ }
+
+ *status = 0;
+ return;
+}
+/***************************************************************/
+/*
+ * Transform gridded data from one registered grid geometry to another.
+ */
+void grid_map(geom_a, geom_b, fbuff_a, fbuff_b, status)
+REG_GEOM *geom_a; /* geom structure from isdb.h - input grid */
+REG_GEOM *geom_b; /* geom structure from isdb.h - output grid */
+float *fbuff_a; /* array containing grid values - input */
+float *fbuff_b; /* array containing grid values - output */
+int *status; /* return status from routine */
+{
+ long i; /* index variable */
+ long j; /* index variable */
+ long index; /* index number for array */
+ float value; /* calculated value of function */
+ double x; /* col within grid */
+ double y; /* row within grid */
+ double lat; /* latitude in degrees */
+ double lon; /* longitude in degrees */
+
+ extern void xy_index();
+ extern void xy_latlon();
+ extern void getf_latlon();
+
+/* Loop over gridpoints of output grid */
+ for(j = 1; j <= geom_b->ny; j++){
+ for(i = 1; i <= geom_b->nx; i++){
+
+ x = (double) i;
+ y = (double) j;
+
+/* Transform the output grid coordinates to lat-lon coordinates */
+ xy_latlon(geom_b, &x, &y, &lat, &lon, status);
+ if (*status < 0) {
+ fprintf(stderr, "Grid_map: Error from xy_latlon\n");
+ return;
+ }
+
+/* Use two-d interpoplation to get value of input grid at lat, lon */
+ getf_latlon(geom_a, &lat, &lon, fbuff_a, &value, status);
+ if (*status < 0) {
+ fprintf(stderr, "Grid_map: Error from getf_latlon\n");
+ return;
+ }
+
+/* Convert from row, col number to linear array index */
+ xy_index(geom_b, &i, &j, &index, status);
+ if (*status < 0) {
+ fprintf(stderr, "Grid_map: Error from xy_index\n");
+ return;
+ }
+
+/* Assign calculated grid point value to grid point */
+ *(fbuff_b + index - 1) = value;
+
+ } /* end of loop over columns */
+ } /* end of loop over rows */
+
+}
+ /* Binary lookup */
+ /* Lookup x, in strictly monotonic vector tab (increasing or decreasing) */
+ /* of length n, return index k. */
+ /* k is interpreted as follows: */
+ /* Case: tab is increasing: */
+ /* k == -1 iff x <= tab[0] */
+ /* k == (n-1) iff x > tab[n-1] */
+ /* else tab[k] < x <= tab[k+1] */
+ /* Case: tab is decreasing: */
+ /* k == -1 iff x > tab[0] */
+ /* k == (n-1) iff x <= tab[n-1] */
+ /* else tab[k] >= x > tab[k+1]*/
+
+void CdLookup(double tab[], long n, double x, long *k)
+{
+ long kupper,kmid,klower;
+ int incr;
+
+ klower=-1;
+ kupper=n;
+ incr=(tab[n-1] > tab[0]);
+ while (kupper-klower > 1) {
+ kmid=(kupper+klower) >> 1;
+ if (x > tab[kmid] == incr)
+ klower=kmid;
+ else
+ kupper=kmid;
+ }
+ *k=klower;
+}
diff --git a/Src/cdTime/timeArith.c b/Src/cdTime/timeArith.c
new file mode 100644
index 0000000..e64a45f
--- /dev/null
+++ b/Src/cdTime/timeArith.c
@@ -0,0 +1,179 @@
+/*
+ * Module: Time arithmetic routines: CdAddDelTime, CdDivDeltime
+ *
+ * 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$
+ *
+ * Revision History:
+ *
+ * $Log: timeArith.c,v $
+ * Revision 1.1.1.1 1997/12/09 18:57:40 drach
+ * Copied from cirrus
+ *
+ * Revision 1.2 1996/02/21 23:56:49 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
+ *
+ * Revision 1.1 1994/07/19 23:54:13 drach
+ * Initial version
+ *
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <cdmsint.h>
+
+/* Add 'nDel' times 'delTime' to epochal time 'begEtm',
+ * return the result in epochal time 'endEtm'.
+ */
+void
+CdAddDelTime(double begEtm, long nDel, CdDeltaTime delTime, CdTimeType timeType,
+ long baseYear, double *endEtm)
+{
+ double delHours;
+ long delMonths, delYears;
+ CdTime bhtime, ehtime;
+
+ extern void Cde2h(double etime, CdTimeType timeType, long baseYear, CdTime *htime);
+ extern void Cdh2e(CdTime *htime, double *etime);
+
+ switch(delTime.units){
+ case CdYear:
+ delMonths = 12;
+ break;
+ case CdSeason:
+ delMonths = 3;
+ break;
+ case CdMonth:
+ delMonths = 1;
+ break;
+ case CdWeek:
+ delHours = 168.0;
+ break;
+ case CdDay:
+ delHours = 24.0;
+ break;
+ case CdHour:
+ delHours = 1.0;
+ break;
+ case CdMinute:
+ delHours = 1./60.;
+ break;
+ case CdSecond:
+ delHours = 1./3600.;
+ break;
+ default:
+ cdError("Invalid delta time units: %d\n",delTime.units);
+ return;
+ }
+
+ switch(delTime.units){
+ case CdYear: case CdSeason: case CdMonth:
+ Cde2h(begEtm,timeType,baseYear,&bhtime);
+ delMonths = delMonths * nDel * delTime.count + bhtime.month - 1;
+ delYears = (delMonths >= 0 ? (delMonths/12) : (delMonths+1)/12 - 1);
+ ehtime.year = bhtime.year + delYears;
+ ehtime.month = delMonths - (12 * delYears) + 1;
+ ehtime.day = 1;
+ ehtime.hour = 0.0;
+ ehtime.timeType = timeType;
+ ehtime.baseYear = !(timeType & CdChronCal) ? 0 :
+ (timeType & CdBase1970) ? 1970 : baseYear; /* base year is 0 for Clim, */
+ /* 1970 for Chron, */
+ /* or input base year for Rel */
+ Cdh2e(&ehtime,endEtm);
+ break;
+ case CdWeek: case CdDay: case CdHour: case CdMinute: case CdSecond:
+ delHours *= (nDel * delTime.count);
+ *endEtm = begEtm + delHours;
+ break;
+ }
+ return;
+}
+
+/* Divide ('endEtm' - 'begEtm') by 'delTime',
+ * return the integer portion of the result in 'nDel'.
+ */
+void
+CdDivDelTime(double begEtm, double endEtm, CdDeltaTime delTime, CdTimeType timeType,
+ long baseYear, long *nDel)
+{
+ double delHours, frange;
+ long delMonths, range;
+ CdTime bhtime, ehtime;
+ int hoursInYear;
+
+ extern void Cde2h(double etime, CdTimeType timeType, long baseYear, CdTime *htime);
+
+ switch(delTime.units){
+ case CdYear:
+ delMonths = 12;
+ break;
+ case CdSeason:
+ delMonths = 3;
+ break;
+ case CdMonth:
+ delMonths = 1;
+ break;
+ case CdWeek:
+ delHours = 168.0;
+ break;
+ case CdDay:
+ delHours = 24.0;
+ break;
+ case CdHour:
+ delHours = 1.0;
+ break;
+ case CdMinute:
+ delHours = 1./60.;
+ break;
+ case CdSecond:
+ delHours = 1./3600.;
+ break;
+ default:
+ cdError("Invalid delta time units: %d\n",delTime.units);
+ return;
+ }
+
+ switch(delTime.units){
+ case CdYear: case CdSeason: case CdMonth:
+ delMonths *= delTime.count;
+ Cde2h(begEtm,timeType,baseYear,&bhtime);
+ Cde2h(endEtm,timeType,baseYear,&ehtime);
+ if(timeType & CdChronCal){ /* Chron and Rel time */
+ range = 12*(ehtime.year - bhtime.year)
+ + (ehtime.month - bhtime.month);
+ }
+ else{ /* Clim time, ignore year */
+ range = (ehtime.month - bhtime.month);
+ if(range < 0) range += 12;
+ }
+ *nDel = abs(range)/delMonths;
+ break;
+ case CdWeek: case CdDay: case CdHour: case CdMinute: case CdSecond:
+ delHours *= (double)delTime.count;
+ if(timeType & CdChronCal){ /* Chron and Rel time */
+ frange = fabs(endEtm - begEtm);
+ }
+ else{ /* Clim time, ignore year, but */
+ /* wraparound relative to hours-in-year*/
+ frange = endEtm - begEtm;
+ hoursInYear = (timeType & Cd365) ? 8760. : 8640.;
+ /* Normalize frange to interval [0,hoursInYear) */
+ if(frange < 0.0 || frange >= hoursInYear)
+ frange -= hoursInYear * floor(frange/hoursInYear);
+ }
+ *nDel = (frange + 1.e-10*delHours)/delHours;
+ break;
+ }
+ return;
+}
diff --git a/Src/cdTime/timeConv.c b/Src/cdTime/timeConv.c
new file mode 100644
index 0000000..3b0513f
--- /dev/null
+++ b/Src/cdTime/timeConv.c
@@ -0,0 +1,396 @@
+/*
+ * Module: Basic time format conversion routines:
+ * Cdc2e, Cdc2h, Cde2c, Cde2h, Cdh2c, Cdh2e
+ *
+ * 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$
+ *
+ * Revision History:
+ *
+ * $Log: timeConv.c,v $
+ * Revision 1.2 1998/02/20 00:24:49 drach
+ * - Added multi-variable file spanning in QL
+ * - Accounted for goofy floor function on J90, in timeConv.c
+ *
+ * Revision 1.1.1.1 1997/12/09 18:57:40 drach
+ * Copied from cirrus
+ *
+ * Revision 1.4 1996/02/21 23:56:50 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
+ *
+ * Revision 1.3 1994/08/12 19:03:30 drach
+ * Added CdDaysInMonth function so that CdSetTime can handle last-day-of-month flag.
+ *
+ * Revision 1.2 1994/07/20 00:01:17 drach
+ * - Changed unsigned struct values to signed
+ * - Added baseYear argument to Cdc2e
+ *
+ * Revision 1.1 1994/07/13 18:29:44 drach
+ * Initial version
+ *
+ *
+ */
+
+#include <math.h>
+#include <stdio.h>
+#include <cdmsint.h>
+
+#define ISLEAP(year,timeType) (((timeType) & CdHasLeap) && (!((year) % 4) && (((timeType) & CdJulianType) || (((year) % 100) || !((year) % 400)))))
+
+static int mon_day_cnt[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
+static int days_sum[12] = {0,31,59,90,120,151,181,212,243,273,304,334};
+
+/* Compute month and day from year and day-of-year.
+ *
+ * Input:
+ * doy (int) (day-of-year)
+ * date->year (long) (year since 0 BC)
+ * date->timeType (CdTimetype) (time type)
+ * date->baseYear base year for relative times
+ * Output:
+ * date->month (short) (month in year)
+ * date->day (short) (day in month)
+ *
+ *
+ * Derived from NRL NEONS V3.6.
+ */
+
+void
+CdMonthDay(int *doy, CdTime *date)
+{
+ int i; /* month counter */
+ int idoy; /* day of year counter */
+ long year;
+
+ if ((idoy = *doy) < 1) {
+ date->month = 0;
+ date->day = 0;
+ return;
+ }
+
+ if(!(date->timeType & CdChronCal)) /* Ignore year for Clim calendar */
+ year = 0;
+ else if(!(date->timeType & CdBase1970)) /* year is offset from base for relative time */
+ year = date->baseYear + date->year;
+ else
+ year = date->year;
+
+ if (ISLEAP(year,date->timeType)) {
+ mon_day_cnt[1] = 29;
+ } else {
+ mon_day_cnt[1] = 28;
+ }
+ date->month = 0;
+ for (i = 0; i < 12; i++) {
+ (date->month)++;
+ date->day = idoy;
+ if ((idoy -= ((date->timeType & Cd365) ? (mon_day_cnt[date->month-1]) : 30)) <= 0) {
+ return;
+ }
+ }
+ return;
+}
+
+
+/* Compute number of days in a month
+ *
+ * Input:
+ * date->year (long) (year since 0 BC)
+ * date->month (short) (month in year)
+ * date->timeType (CdTimetype) (time type)
+ * date->baseYear base year for relative times
+ *
+ * Output:
+ * days (short) (number of days in month)
+ *
+ */
+
+void
+CdDaysInMonth(CdTime *date, int *days)
+{
+ long year;
+
+ if(!(date->timeType & CdChronCal)) /* Ignore year for Clim calendar */
+ year = 0;
+ else if(!(date->timeType & CdBase1970)) /* year is offset from base for relative time */
+ year = date->baseYear + date->year;
+ else
+ year = date->year;
+
+ if (ISLEAP(year,date->timeType)) {
+ mon_day_cnt[1] = 29;
+ } else {
+ mon_day_cnt[1] = 28;
+ }
+
+ *days = (date->timeType & Cd365) ? (mon_day_cnt[date->month-1]) : 30;
+
+ return;
+}
+
+/* Compute day-of-year from year, month and day
+ *
+ * Input:
+ * date->year (long) (year since 0 BC)
+ * date->month (short) (month in year)
+ * date->day (short) (day in month)
+ * date->baseYear base year for relative times
+ * Output: doy (int) (day-of-year)
+ *
+ * Derived from NRL NEONS V3.6
+ */
+
+void
+CdDayOfYear(CdTime *date, int *doy)
+{
+ int leap_add = 0; /* add 1 day if leap year */
+ int month; /* month */
+ long year;
+
+ month = date->month;
+ if (month < 1 || month > 12) {
+ cdError( "Day-of-year error; month: %d\n", month);
+ month = 1;
+ }
+
+ if(!(date->timeType & CdChronCal)) /* Ignore year for Clim calendar */
+ year = 0;
+ else if(!(date->timeType & CdBase1970)) /* year is offset from base for relative time */
+ year = date->baseYear + date->year;
+ else
+ year = date->year;
+
+ if (ISLEAP(year,date->timeType) && month > 2) leap_add = 1;
+ *doy = ((date->timeType & Cd365) ? (days_sum[month-1]) : 30*(month-1)) + date->day + leap_add;
+ return;
+}
+/* Convert human time to epochal time (hours since 00 jan 1, 1970)
+ *
+ * Input: htime = human time representation
+ *
+ * Output: etime = epochal time representation
+ *
+ * Derived from NRL Neons V3.6
+ */
+void
+Cdh2e(CdTime *htime, double *etime)
+{
+ long ytemp, year; /* temporary year holder */
+ int day_cnt; /* count of days */
+ int doy; /* day of year */
+ long baseYear; /* base year for epochal time */
+ int daysInLeapYear; /* number of days in a leap year */
+ int daysInYear; /* days in non-leap year */
+ extern void CdDayOfYear(CdTime *date, int *doy);
+
+ CdDayOfYear(htime,&doy);
+
+ day_cnt = 0;
+
+ baseYear = ((htime->timeType) & CdBase1970) ? 1970 : htime->baseYear;
+ year = ((htime->timeType) & CdBase1970) ? htime->year : (htime->year + htime->baseYear);
+ if(!((htime->timeType) & CdChronCal)) baseYear = year = 0; /* set year and baseYear to 0 for Clim */
+ daysInLeapYear = ((htime->timeType) & Cd365) ? 366 : 360;
+ daysInYear = ((htime->timeType) & Cd365) ? 365 : 360;
+
+ if (year > baseYear) {
+ for (ytemp = year - 1; ytemp >= baseYear; ytemp--) {
+ day_cnt += ISLEAP(ytemp,htime->timeType) ? daysInLeapYear : daysInYear;
+ }
+ } else if (year < baseYear) {
+ for (ytemp = year; ytemp < baseYear; ytemp++) {
+ day_cnt -= ISLEAP(ytemp,htime->timeType) ? daysInLeapYear : daysInYear;
+ }
+ }
+ *etime = (double) (day_cnt + doy - 1) * 24. + htime->hour;
+ return;
+}
+/* Convert epochal time (hours since 00 jan 1, 1970)
+ * to human time (structured)
+ *
+ * Input:
+ * etime = epochal time representation
+ * timeType = time type (e.g., CdChron, CdClim, etc.) as defined in cdms.h
+ * baseYear = base real, used for relative time types only
+ *
+ * Output: htime = human (structured) time representation
+ *
+ * Derived from NRL Neons V3.6
+ */
+void
+Cde2h(double etime, CdTimeType timeType, long baseYear, CdTime *htime)
+{
+ long ytemp; /* temporary year holder */
+ int yr_day_cnt; /* count of days in year */
+ int doy; /* day of year */
+ int daysInLeapYear; /* number of days in a leap year */
+ int daysInYear; /* days in non-leap year */
+ extern void CdMonthDay(int *doy, CdTime *date);
+
+ doy = (long) floor(etime / 24.) + 1;
+ htime->hour = etime - (double) (doy - 1) * 24.;
+
+ /* Correct for goofy floor func on J90 */
+ if(htime->hour >= 24.){
+ doy += 1;
+ htime->hour -= 24.;
+ }
+
+ htime->baseYear = (timeType & CdBase1970) ? 1970 : baseYear;
+ if(!(timeType & CdChronCal)) htime->baseYear = 0; /* Set base year to 0 for Clim */
+ daysInLeapYear = (timeType & Cd365) ? 366 : 360;
+ daysInYear = (timeType & Cd365) ? 365 : 360;
+
+ if (doy > 0) {
+ for (ytemp = htime->baseYear; ; ytemp++) {
+ yr_day_cnt = ISLEAP(ytemp,timeType) ? daysInLeapYear : daysInYear;
+ if (doy <= yr_day_cnt) break;
+ doy -= yr_day_cnt;
+ }
+ } else {
+ for (ytemp = htime->baseYear-1; ; ytemp--) {
+ yr_day_cnt = ISLEAP(ytemp,timeType) ? daysInLeapYear : daysInYear;
+ doy += yr_day_cnt;
+ if (doy > 0) break;
+ }
+ }
+ htime->year = (timeType & CdBase1970) ? ytemp : (ytemp - htime->baseYear);
+ if(!(timeType & CdChronCal)) htime->year = 0; /* Set year to 0 for Clim */
+ htime->timeType = timeType;
+ CdMonthDay(&doy,htime);
+
+ return;
+}
+/* Convert character time to human time
+ *
+ * Input:
+ * ctime = character time
+ * timeType = time type (e.g. CdChron) as defined in cdms.h
+ *
+ * Output:
+ * htime = human (structured) time
+ */
+void
+Cdc2h(char *ctime, CdTimeType timeType, CdTime *htime)
+{
+/* int iyear, imon, iday, ihour, imin; */
+ int ihour, imin;
+ double dsec;
+/* long baseYear; */
+
+ switch(timeType){
+ case CdChron: case CdChronNoLeap: case CdChron360:
+ sscanf(ctime,"%ld/%hd/%hd %d:%d:%lf",&htime->year,&htime->month,
+ &htime->day,&ihour,&imin,&dsec);
+ htime->hour = (double)ihour + (double)imin/60. + dsec/3600;
+ htime->baseYear = 1970;
+ htime->timeType = timeType;
+ break;
+ case CdRel: case CdRelNoLeap:
+ sscanf(ctime,"%ld+%ld/%hd/%hd %d:%d:%lf",&htime->baseYear,
+ &htime->year,&htime->month,&htime->day,&ihour,&imin,&dsec);
+ htime->hour = (double)ihour + (double)imin/60. + dsec/3600;
+ htime->timeType = timeType;
+ break;
+ case CdClim:
+ sscanf(ctime,"%hd/%hd %d:%d:%lf",&htime->month,&htime->day,
+ &ihour,&imin,&dsec);
+ htime->hour = (double)ihour + (double)imin/60. + dsec/3600;
+ htime->year = 0;
+ htime->baseYear = 0;
+ htime->timeType = timeType;
+ break;
+ default:
+ cdError("Invalid time type: %d\n",timeType);
+ }
+ return;
+}
+/* Convert human (structured) time to character time.
+ *
+ * Input:
+ * htime = human time
+ *
+ * Output:
+ * ctime = character time
+ */
+void
+Cdh2c(CdTime *htime, char *ctime)
+{
+
+ int ihour, imin;
+ double dmin, dsec;
+
+ ihour = (int) htime->hour;
+ dmin = (htime->hour - (double)ihour) * 60.0;
+ imin = (int) dmin;
+ dsec = (dmin - (double)imin) * 60.0;
+
+ switch(htime->timeType){
+ case CdChron: case CdChronNoLeap: case CdChron360:
+ sprintf(ctime,"%ld/%hd/%hd %d:%d:%.1f",htime->year,htime->month,
+ htime->day,ihour,imin,dsec);
+ break;
+ case CdRel: case CdRelNoLeap:
+ sprintf(ctime,"%ld+%ld/%hd/%hd %d:%d:%.1f",htime->baseYear,
+ htime->year,htime->month,htime->day,ihour,imin,dsec);
+ break;
+ case CdClim:
+ sprintf(ctime,"%hd/%hd %d:%d:%.1f",htime->month,htime->day,
+ ihour,imin,dsec);
+ break;
+ default:
+ cdError("Invalid time type: %d\n",htime->timeType);
+
+ }
+ return;
+}
+/* Convert character time to epochal time (hours since 00 jan 1, 1970)
+ *
+ * Input:
+ * ctime = character time
+ * timeType = time type (e.g. CdChron) as defined in cdms.h
+ *
+ * Output:
+ * etime = epochal time
+ */
+void
+Cdc2e(char *ctime, CdTimeType timeType, double *etime, long *baseYear)
+{
+ CdTime htime;
+ extern void Cdc2h(char *ctime, CdTimeType timeType, CdTime *htime);
+ extern void Cdh2e(CdTime *htime, double *etime);
+
+ Cdc2h(ctime,timeType,&htime);
+ Cdh2e(&htime,etime);
+ *baseYear = htime.baseYear;
+ return;
+}
+/* Convert epochal time (hours since 00 jan 1, 1970) to character time
+ *
+ * Input:
+ * etime = epochal time
+ * timeType = time type, (e.g., CdChron) as defined in cdms.h
+ * baseYear = base year, used for relative time only
+ *
+ * Output:
+ * ctime = character time
+ */
+void
+Cde2c(double etime, CdTimeType timeType, long baseYear, char *ctime)
+{
+ CdTime htime;
+ extern void Cde2h(double etime, CdTimeType timeType, long baseYear, CdTime *htime);
+ extern void Cdh2c(CdTime *htime, char *ctime);
+
+ Cde2h(etime,timeType,baseYear,&htime);
+ Cdh2c(&htime,ctime);
+ return;
+}
diff --git a/include/cdTime/cddrs.h b/include/cdTime/cddrs.h
new file mode 100644
index 0000000..cad5837
--- /dev/null
+++ b/include/cdTime/cddrs.h
@@ -0,0 +1,151 @@
+/* -*-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$
+ *
+ * Revision History:
+ *
+ * $Log: cddrs.h,v $
+ * 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/include/cdTime/cddrsint.h b/include/cdTime/cddrsint.h
new file mode 100644
index 0000000..bd9e892
--- /dev/null
+++ b/include/cdTime/cddrsint.h
@@ -0,0 +1,107 @@
+/* -*-Mode: C;-*-
+ * Module: cddrsint.h - internal include file for 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$
+ *
+ * Revision History:
+ *
+ * $Log: cddrsint.h,v $
+ * Revision 1.7 1995/06/09 22:44:16 drach
+ * Added extensions for string length and dimension types
+ *
+ * Revision 1.6 1995/03/09 00:35:16 drach
+ * Added netCDF, upgraded cureadarray with casting, user-specified indices
+ *
+ * Revision 1.5 1995/01/21 00:53:18 drach
+ * - Recognize "" as a string null, since cfortran.h trims " "
+ *
+ * Revision 1.4 1995/01/13 01:03:57 drach
+ * Added vdims fields:
+ * - values (dimension cache), isCycle, and cycle
+ * - Added cw_lookup_cycle, cw_dimget, cw_unif_to_drs_datatype
+ *
+ * Revision 1.3 1994/12/17 00:42:51 drach
+ * - Define CW_IS_FLOAT_NULL
+ *
+ * Revision 1.2 1994/12/16 00:45:23 drach
+ * - Added string match macro
+ * - Added isset
+ * - Added several function declarations
+ *
+ * Revision 1.1 1994/12/14 02:33:53 drach
+ * - Added to CVS
+ *
+ *
+ */
+
+#ifndef __cddrsint_h
+#define __cddrsint_h
+
+#include <string.h>
+#include <math.h>
+#include "drscdf.h"
+#include "cddrs.h"
+
+ /* Set and null-terminate a VDB string
+ * Note that either NULL, "" or " " are treated
+ * as null strings.
+ */
+#define VDB_STRING_SET(d,s,n) {strncpy((d),((s && strcmp(s,"")) ? s : CW_STRING_NULL),(n));(d)[(n)-1]='\0';cw_strtrim((d));}
+#define CW_STRING_MATCH(s,t) ((!strcmp((s),CW_STRING_NULL))||(!strcmp((t),CW_STRING_NULL))||(!strcmp((s),(t))))
+#define CW_IS_FLOAT_NULL(x) (fabs((x)-CW_FLOAT_NULL)<=CW_FLOAT_DELTA)
+
+typedef struct {
+ int filelu; /* Dictionary file logical unit */
+ char source[CU_MAX_NAME]; /* DRS source string */
+ char name[CU_MAX_NAME]; /* DRS variable name */
+ char title[CU_MAX_NAME]; /* DRS variable title */
+ char units[CU_MAX_NAME]; /* DRS variable units */
+ char date[CU_MAX_NAME]; /* DRS date written */
+ char time[CU_MAX_NAME]; /* DRS time written */
+ char type[CU_MAX_NAME]; /* type string, e.g., 'R*4' */
+ int ndims; /* number of dimensions */
+} CwVar;
+
+typedef struct {
+ char source[CU_MAX_NAME]; /* source string */
+ char name[CU_MAX_NAME]; /* DRS dimension name */
+ char title[CU_MAX_NAME]; /* DRS dimension title */
+ char units[CU_MAX_NAME]; /* DRS dimension units */
+ int type; /* IDRS_EQUALLY_SPACED | IDRS_UNEQUALLY_SPACED | IDRS_IMPLICIT_VECTOR */
+ double dfreq; /* first value of requested dimension range */
+ double dlreq; /* first value of requested dimension range */
+ double dfactual; /* first value of range as received */
+ double dlactual; /* first value of range as received */
+ int len; /* number of values in the dimension */
+ int reqlen; /* number of values requested */
+ int isset; /* True iff cw_setdim or cw_setvdim has been called */
+ /* since the last cw_cllun call.*/
+ double* values; /* Actual values, or double** 0 if not cached */
+ int isCycle; /* 1 iff dimension is cyclical */
+ double cycle; /* dimension period, if isCycle */
+} CwDim;
+
+extern int cw_geterr PROTO((void));
+extern void cw_error PROTO((char *fmt, ...));
+extern void cw_lookup PROTO((double tab[], long n, double x, long *k));
+extern int cw_lookup_cycle PROTO((double tab[], long n, double x, double cycle, CwRoundPolicy policy, double delta, long *k, long *icycle));
+extern int cw_lookup_with_policy PROTO((double tab[], long n, double x, CwRoundPolicy policy, double delta, long *k));
+extern int cw_dimget PROTO((int fileid, int dimid, double** values, long *dimlen));
+extern int cw_dimmap PROTO((int fileid, int dimid, double df, double dl, CwRoundPolicy policy, double delta, int isCycle, double cycle, double **dp, long *idf, long *idl, double *xdf, double *xdl));
+extern int cw_varid PROTO((int fileid, const char* source, const char* name, const char* title, const char* units));
+extern int cw_string_attget PROTO((int fileid, int varid, const char* attname, char* value));
+extern CuType cw_drs_to_unif_datatype PROTO((const char* drstype));
+extern int cw_unif_to_drs_datatype PROTO((CuType dtype, char* drstype));
+extern int cw_unif_to_drs_enumtype PROTO((CuType dtype, int* enumtype));
+extern void cw_add_extension PROTO((const char* filename, const char* extension, char* result));
+extern char* cw_strtrim PROTO((char* s));
+extern int cw_dimension_varid PROTO((int fileid, int dimid, char* dname));
+
+#endif
diff --git a/include/cdTime/cdms.h b/include/cdTime/cdms.h
new file mode 100644
index 0000000..84c8c03
--- /dev/null
+++ b/include/cdTime/cdms.h
@@ -0,0 +1,319 @@
+/*
+ * 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$
+ *
+ * Revision History:
+ *
+ * $Log: cdms.h,v $
+ * 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);
+#ifdef __cplusplus
+extern "C"
+#else
+extern
+#endif
+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/include/cdTime/cdms.inc b/include/cdTime/cdms.inc
new file mode 100644
index 0000000..bba349e
--- /dev/null
+++ b/include/cdTime/cdms.inc
@@ -0,0 +1,57 @@
+c -*-Mode: Fortran;-*-
+c Module: cdms.inc - CDMS Fortran API include file
+c
+c Copyright: 1996, Regents of the University of California
+c This software may not be distributed to others without
+c permission of the author.
+c
+c Author: Bob Drach, Lawrence Livermore National Laboratory
+c drach at llnl.gov
+c
+c Version: $Id$
+c
+c Revision History:
+c
+c $Log: cdms.inc,v $
+c Revision 1.1 1996/04/04 22:36:02 drach
+c - Initial version
+c
+c
+
+c
+c Declarations
+c
+ external fcdchar2comp, fcdchar2rel, fcdcomp2char
+ external fcdcomp2rel, fcdrel2char, fcdrel2comp
+ external fcdrel2rel
+
+ integer CD_STANDARD, CD_JULIAN, CD_NOLEAP, CD_360, CD_CLIM
+ integer CD_CLIMLEAP, CD_CLIM360, CD_NULL_YEAR, CD_NULL_MONTH
+ integer CD_LAST_DAY, CD_MAX_CHARTIME, CD_MAX_TIME_DELTA
+ integer CD_NULL_DAY
+ double precision CD_NULL_HOUR
+c
+c Time types and parameters
+c
+ parameter(CD_STANDARD = '00001111'X)
+ parameter(CD_JULIAN = '00011111'X)
+ parameter(CD_MIXED = '00021111'X)
+ parameter(CD_NOLEAP = '00001011'X)
+ parameter(CD_360 = '00000011'X)
+ parameter(CD_CLIM = '00001000'X)
+ parameter(CD_CLIMLEAP = '00001100'X)
+ parameter(CD_CLIM360 = '00000000'X)
+
+ parameter(CD_NULL_YEAR = 0)
+ parameter(CD_NULL_MONTH = 1)
+ parameter(CD_LAST_DAY = 1)
+ parameter(CD_MAX_CHARTIME = 48)
+ parameter(CD_MAX_TIME_DELTA = 64)
+ parameter(CD_NULL_DAY = 1)
+ parameter(CD_NULL_HOUR = 0.0)
+
+
+
+
+
+
diff --git a/include/cdTime/cdmsint.h b/include/cdTime/cdmsint.h
new file mode 100644
index 0000000..9e7dcaa
--- /dev/null
+++ b/include/cdTime/cdmsint.h
@@ -0,0 +1,588 @@
+/* -*-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$
+ *
+ * Revision History:
+ *
+ * $Log: cdmsint.h,v $
+ * 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) && !defined(__x86_64__) && !defined(__ia64)
+#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/include/cdTime/cdmsint_new.h b/include/cdTime/cdmsint_new.h
new file mode 100644
index 0000000..05347fd
--- /dev/null
+++ b/include/cdTime/cdmsint_new.h
@@ -0,0 +1,1063 @@
+/* psql structs, pointers, defines */
+
+#ifndef _PSQL_H
+#define _PSQL_H
+
+#include <stdio.h>
+#include <math.h>
+#include <stdarg.h>
+#include <cdms.h>
+#include <string.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <netcdf.h>
+#include <pwd.h>
+#include <grp.h>
+#include <sys/types.h>
+#include <time.h>
+#include <ctype.h>
+
+
+/*--------------------------------------------------------------------
+ * Integer ID numbers for CDMS tree nodes
+ *-------------------------------------------------------------------*/
+
+
+typedef enum {
+ id_cdNone = 4321,
+ id_cdHd,
+ id_cdTmp,
+ id_cdPql,
+ id_cdDb,
+ id_cdDset,
+ id_cdVar,
+ id_cdDim,
+ id_cdAtt
+} cdms_Id;
+
+
+/*--------------------------------------------------------------------
+ * PQL keywords and enumerations
+ *-------------------------------------------------------------------*/
+
+
+#define L_pql 42 /* number of pql keywords */
+#define L_pql_node_type 5 /* number of pql tree node identifiers */
+
+enum { i_database, i_dataset, i_variable, i_dimension, i_attribute,
+ i_select, i_distinct, i_at, i_below, i_above,
+ i_name, i_value, i_length, i_where, i_union,
+ i_show, i_id, i_from, i_dirtree, i_end,
+ i_readmeta, i_writemeta, i_pwd, i_tempmount, i_group,
+ i_release, i_read, i_cd, i_virtual, i_ndim,
+ i_ttycopy, i_with, i_for, i_filename, i_readcheck,
+ i_type, i_check, i_alter, i_readalter, i_subfgroup,
+ i_writeds, i_lenreadbuf };
+
+#ifndef PSQL
+char *pqlkey[L_pql] = {
+ "database", "dataset", "variable", "dimension", "attribute",
+ "select", "distinct", "at", "below", "above",
+ "name", "value", "length", "where", "union",
+ "show", "id", "from", "dirtree", "end",
+ "readmeta", "writemeta", "pwd", "tempmount", "group",
+ "release", "read", "cd", "virtual", "ndim",
+ "ttycopy", "with", "for", "filename", "readcheck",
+ "type", "check", "alter", "readalter", "subfgroup",
+ "writeds", "lenreadbuf" };
+
+cdms_Id pqlnode[L_pql_node_type] = {
+ id_cdDb, id_cdDset, id_cdVar, id_cdDim, id_cdAtt };
+#else
+extern char *pqlkey[];
+extern cdms_Id pqlnode[];
+#endif
+
+
+/**********************************************************************/
+ /* Database */
+/**********************************************************************/
+
+
+typedef struct cdDb_n {
+ cdms_Id id; /* id identifier of this struct */
+ cdms_Id id_above; /* id struct above this struct */
+ void *above; /* struct above this struct */
+ char *name; /* Database name */
+ struct cdDset_n *dsets; /* Datasets */
+ struct cdVar_n *vars; /* Variables */
+ struct cdDim_n *dims; /* Dimensions */
+ struct cdAtt_n *atts; /* Attributes */
+ struct cdPql_n *pqls; /* Pql lists */
+ struct cdDb_n *next; /* Next database */
+ struct cdCheck_n *ckdefs; /* Check Var,Dim,Att def. */
+ struct cdDbFlag_n *f; /* Global scalars, flags */
+} cdDb_new;
+
+
+/**********************************************************************/
+ /* Dataset */
+/**********************************************************************/
+
+
+typedef struct cdDset_n {
+ cdms_Id id; /* id identifier of this struct */
+ cdms_Id id_above; /* id struct above this struct */
+ void *above; /* struct above this struct */
+ char *name; /* Dataset name */
+ struct cdVar_n *vars; /* Variables */
+ struct cdDim_n *dims; /* Dimensions */
+ struct cdAtt_n *atts; /* Attributes */
+ struct cdDset_n *next; /* Next dataset */
+} cdDset_new;
+
+
+/**********************************************************************/
+ /* Variable */
+/**********************************************************************/
+
+
+typedef struct cdVar_n {
+ cdms_Id id; /* id identifier of this struct */
+ cdms_Id id_above; /* id struct above this struct */
+ void *above; /* struct above this struct */
+ char *name; /* Parameter name (official) */
+ struct cdAtt_n *atts; /* Attributes */
+ int ndims; /* Number of dimensions */
+ struct cdTmp_n *dim; /* Dimension IDs (in dim order) */
+ cdType datatype; /* cdChar, cdInt, etc. */
+ long length; /* Number of elements */
+ void *data; /* Data for implicit definition */
+ struct cdVar_n *next; /* Next Variable */
+} cdVar_new;
+
+
+/**********************************************************************/
+ /* Dimension */
+/**********************************************************************/
+
+
+typedef struct cdDim_n {
+ cdms_Id id; /* id identifier of this struct */
+ cdms_Id id_above; /* id struct above this struct */
+ void *above; /* struct above this struct */
+ char *name; /* Dimension name */
+ struct cdAtt_n *atts; /* Attributes */
+ char *units; /* Units*/
+ cdType datatype; /* Dimension datatype */
+ long length; /* Number of elements */
+ void *data; /* coordinates if not cdLinear */
+ struct cdDim_n *next; /* Next Dimension */
+} cdDim_new;
+
+
+/**********************************************************************/
+ /* Attribute */
+/**********************************************************************/
+
+
+typedef struct cdAtt_n {
+ cdms_Id id; /* id identifier of this struct */
+ cdms_Id id_above; /* id struct above this struct */
+ void *above; /* struct above this struct */
+ char *name; /* Attribute name */
+ cdType datatype; /* Datatype of the attribute */
+ long length; /* Number of elements (NOT bytes) */
+ void *values; /* Attribute values */
+ struct cdAtt_n *next; /* Next Attribute */
+} cdAtt_new;
+
+
+/**********************************************************************/
+ /* Struct Header */
+/**********************************************************************/
+
+
+typedef struct cdHd_n {
+ cdms_Id id; /* id identifier of this struct */
+ cdms_Id id_above; /* id struct above this struct */
+ void *above; /* struct above this struct */
+} cdHd;
+
+
+/**********************************************************************/
+ /* Substitution Struct -- placeholder pointer of desired struct */
+/**********************************************************************/
+
+
+typedef struct cdTmp_n {
+ cdms_Id id; /* id identifier of this struct */
+ cdms_Id id_above; /* id struct above this struct */
+ void *above; /* struct above this struct */
+ struct cdTmp_n *next; /* next Tempory */
+ cdms_Id id_want; /* id of wanted struct */
+ char *nam_want; /* name of wanted struct */
+ void *want; /* address wanted struct */
+} cdTmp;
+
+
+/**********************************************************************/
+ /* PQL List Selection Struct -- list of tree struct addresses */
+/**********************************************************************/
+
+
+typedef struct cdPql_n {
+ cdms_Id id; /* id identifier of this struct */
+ cdms_Id id_above; /* id struct above this struct */
+ void *above; /* struct above this struct */
+ struct cdPql_n *next; /* next List */
+ char *name; /* Pql name */
+ char *pqlmsg; /* user's input pql instruction */
+ long length; /* length of user's list */
+ long *list; /* list as user-ID's */
+} cdPql;
+
+
+/**********************************************************************/
+ /* internal -- PQL read in sub-set of dataset variable */
+/**********************************************************************/
+
+
+typedef struct var_pql_read_n {
+ struct cdVar_n *var; /* Variable struct */
+ void *data; /* data array */
+ char *path; /* input file directory */
+ char *file; /* input file */
+
+ /*------- Input file Variable info -------*/
+ int ndims; /* Variable number of dimensions */
+ cdType vtyp; /* Variable datatype */
+ long vlen; /* Variable length */
+ int *dorder; /* Variable dim transposing */
+
+ /*------- Input file per-dimension Variable info -------*/
+ struct cdDim_n **dims; /* Dimension struct */
+ char ***plst; /* Pathlist attribute or NULL */
+ char ***flst; /* Filelist attribute or NULL */
+ int **ilst; /* Poslist attribute or NULL */
+ int **fpt; /* Filepoint attribute or NULL */
+
+ long *index; /* User want index */
+ long *count; /* User want count */
+
+ long *rdidx; /* Read file index */
+ long *rdcnt; /* Read file count */
+ long *memidx; /* Read file to memory array index */
+
+ /* REMOVE FROM STRUCT per-dimension info */
+ long *len; /* Coordinate length */
+ cdType *typ; /* Coordinate datatype */
+ void **cord; /* Coordinate array */
+} var_pql_read;
+
+
+/**********************************************************************/
+ /* internal -- PQL read in sub-set of dataset variable */
+/**********************************************************************/
+
+
+typedef struct dim_pql_read_n {
+ struct cdDim_n *dim; /* Dimension struct */
+ void *data; /* data array */
+
+ /*------- Input file Dimension info -------*/
+ cdType dtyp; /* Dimension datatype */
+ long index; /* User want index */
+ long count; /* User want count */
+} dim_pql_read;
+
+
+/**********************************************************************/
+ /* internal -- PQL list of struct CDMS-tree-node addresses */
+/**********************************************************************/
+
+
+typedef struct cdms_pql_list_n {
+ long L_list; /* physical size of list */
+ long length; /* used length of list */
+ void **list; /* list of struct addresses */
+
+
+ /*------- where clause, input from user card -------*/
+ int flg_sid; /* 1 =, 2 !=, 3 <, 4 <=, 5 >, 6 >= */
+ long tst_sid; /* length test arg. */
+
+ int flg_nam; /* 1 =, 2 !=, 3 <, 4 <=, 5 >, 6 >= */
+ char *tst_nam; /* name test arg. */
+
+ int flg_len; /* 1 =, 2 !=, 3 <, 4 <=, 5 >, 6 >= */
+ long tst_len; /* length test arg. */
+
+ int flg_typ; /* 1 =, 2 !=, 3 <, 4 <=, 5 >, 6 >= */
+ char *tst_typ; /* type test arg. */
+
+ int flg_val; /* 1 =, 2 !=, 3 <, 4 <=, 5 >, 6 >= */
+ cdType tst_vtyp; /* type of the value test arg. */
+ char *tst_a_val; /* ascii value test */
+ long tst_i_val; /* integer value test */
+ double tst_f_val; /* floating value test */
+
+ int flg_dim; /* 1 =, 2 !=, 3 <, 4 <=, 5 >, 6 >= */
+ long tst_dim; /* ndim test arg. */
+
+ int flg_v1d; /* 1 =, 2 !=, 3 <, 4 <=, 5 >, 6 >= */
+ /* variable name = dimension name test */
+
+ int flg_grp; /* 1 =, 2 !=, 3 <, 4 <=, 5 >, 6 >= */
+ /* dataset used in f-spanning-group */
+
+
+ /*------- where clause, input from tree-node -------*/
+ long nod_sid; /* length test arg. */
+
+ char *nod_nam; /* name test arg. */
+
+ long nod_len; /* length test arg. */
+
+ cdType nod_typ; /* type test arg. */
+
+ cdType nod_vtyp; /* type of the value test arg. */
+ void *nod_val; /* ascii value test */
+
+ int nod_dim; /* variable number of dimensions */
+
+ int nod_v1d; /* flag for variable==dimension */
+
+ int nod_grp; /* flag for dataset==group */
+
+
+ /*------- show section edit flags -------*/
+ int pflg; /* (0,1) print title lines */
+ int cflg; /* (0,1) print converted dim. values */
+} cdms_pql_list;
+
+
+/**********************************************************************/
+ /* internal -- ascii metafile line, and line symbols */
+/**********************************************************************/
+
+
+typedef struct cdms_card_n {
+ FILE *fp; /* file pointer */
+ char *eof; /* return value from fgets() */
+ int len_line; /* string length of ascii line */
+ char *asc_line; /* ascii line */
+ int num_sym; /* number of symbols */
+ int *idx_sym; /* char-index of symbol */
+ int *len_sym; /* char-length of symbol */
+ int *cls_sym; /* classification of symbol */
+ int L_asc_line; /* memory size of asc_line */
+ int L_idx_sym; /* memory size of idx_sym */
+ /*---------------------------------
+ * cls_sym[] -- classification flag identifying symbol
+ -- (integer of a letter)
+ ( ) < > { } , : ; = " -- special letters
+ 'a' -- symbol, ascii name
+ 'i' -- symbol, integer number
+ 'f' -- symbol, floating number
+ 'q' -- ascii string contained within quotes "..."
+ * idx_sym[] -- index of symbol in ascii input line
+ * len_sym[] -- character length of symbol
+ *---------------------------------*/
+} cdms_card;
+
+
+/**********************************************************************/
+ /* internal -- User-Meta-Disc Variable correspondence */
+/**********************************************************************/
+
+
+#define D_max 8
+
+typedef struct cdms_rd_var_n {
+ /*--------------- disc_to_meta correspondence ---------------*/
+ long f_siz[D_max]; /* disc dimension sizes */
+ long f_len[D_max]; /* length index arrays */
+ long *f_out[D_max]; /* to_meta index arrays */
+
+ /*--------------- user_to_meta correspondence ---------------*/
+ long u_pos[D_max]; /* user position in meta */
+ long u_siz[D_max]; /* user dimension sizes */
+ long u_len[D_max]; /* length index arrays */
+ long *u_in[D_max]; /* to_meta index arrays */
+ struct cdDim_n *u_dim[D_max]; /* user sub-dimensions */
+
+ /*--------------- disc_to_user correspondence ---------------*/
+ long rd_len[D_max]; /* length index arrays */
+ long *rd_in[D_max]; /* read-in index array */
+ long *rd_out[D_max]; /* read-out array */
+
+ /*--------------- general info ---------------*/
+ struct cdVar_n *var; /* meta variable struct */
+ long ndims; /* meta var-dim count */
+ long m_siz[D_max]; /* meta var-dim sizes */
+ struct cdDim_n *m_dim[D_max]; /* meta var-dim structs */
+ char *rd_dir; /* directory path */
+ char *rd_list; /* list of filenames */
+ long nfil; /* number of filenames */
+ long ifil; /* idx current file */
+ int f_id; /* cdunif file id */
+ int f_recdim; /* cdunif file recdim */
+ int f_id_var; /* cdunif file variable id */
+ int f_ndims; /* cdunif file var dim count */
+ int f_dim[D_max]; /* cdunif file var dim id's */
+ int free_flg[8]; /* memory cleanup flags */
+ /* free_flg: 0 f_in, 1 f_out, 2 u_in, 3 u_out,
+ 4 rd_in, 5 rd_out, 6 rd_list, 7 rd_dir */
+} cdms_rd_var;
+
+
+/**********************************************************************/
+ /* internal -- user directory-to-cdms-tree structure */
+/**********************************************************************/
+
+
+typedef struct cdms_dir_n {
+ int db_n; /* number for db names */
+ int ds_n; /* number for dset names */
+ char *aaflag; /* ascii key for db,dset names */
+ int dirflag; /* 0 dir -- db, 1 dir -- dset */
+ int numflag; /* max no. levels to expand */
+ int scnflag; /* 0 -- open file, 1 -- don't */
+ int ownflag; /* file owner flag (0 no, 1 yes) */
+ int conflag; /* 0 -- stop on bad file, 1 -- no */
+ int vmxflag; /* get var. min-max (0 no, 1 yes) */
+ int tmxflag; /* get time bgn-end (0 no, 1 yes) */
+} cdms_dir;
+
+
+/**********************************************************************/
+ /* internal -- add sub-data-file to spanning file declaration */
+/**********************************************************************/
+
+
+typedef struct span_list_n {
+ struct cdDb_n *dbs; /* db of first spaned file */
+ int ct; /* calendar first file */
+
+ /*--------------- dimension card info ---------------*/
+ char *dname; /* name spaning dimension */
+ int flg_dtyp; /* 1 time '1980-1-1 0:0' on cards */
+ int select; /* 0--pt1pt2 cord axis subset, */
+ /* 1--idxidx, 2--idxcnt, */
+ /* 3--offoff, 4--offcnt */
+ char *altf; /* NULL or alterfile */
+ int lvlst; /* length of vlst (from dim card) */
+ char **vlst; /* NULL or variable list */
+
+ /*--------------- filelist size arrays ---------------*/
+ int L_flist; /* size of per-file lists */
+ int n_flist; /* number of files */
+ char **flist; /* list of file names */
+ char **plist; /* list of file paths */
+ int *fdoff; /* list of file-dim offsets */
+
+ /*--------------- coordinate size arrays ---------------*/
+ int L_cord; /* size of coord. arrays */
+ int n_cord; /* number of coordinates */
+ double *scord; /* span coordinate array */
+ int *fpoint; /* filepoint span attribute */
+
+ /*--------------- units,delta card info ---------------*/
+ int flg_del; /* flag, 1 if delta .cdms format */
+ char *uni; /* units first file */
+ int flg_uni; /* 1,2,3 mo,da,6h time flag */
+ double delt; /* delta between coordinates */
+} span_list;
+
+
+/**********************************************************************/
+ /* internal -- pql group instruction */
+/**********************************************************************/
+
+
+typedef struct cdms_group_n {
+ cdVar_new **vlist; /* list of datasets */
+ cdDim_new **dlist; /* list of dimensions */
+ int *index; /* index to coordinates */
+ int *count; /* number of coordinates */
+ int *order; /* sort order position */
+ double *coord; /* coordinates */
+} cdms_group;
+
+
+/**********************************************************************/
+ /* Check Var,Dim,Att Struct */
+/**********************************************************************/
+
+
+typedef struct cdCheck_n {
+ cdms_Id id; /* id identifier of this struct */
+ struct cdCheck_n *next; /* Next Check struct */
+ char *name; /* official name */
+ int L_alias; /* size of **alias */
+ int nalias; /* number of alias */
+ char **alias; /* list of alias names */
+ char *tagname; /* unique identifer name */
+ int L_card; /* size of **card */
+ int ncard; /* number of cards */
+ char **card; /* list of cards */
+ int L_fstruct; /* size of **fstruct */
+ int nfstruct; /* number of struct */
+ cdHd **fstruct; /* list of VAR,DIM,DSET struct */
+} cdCheck;
+
+
+/**********************************************************************/
+ /* Key Global per Database */
+/**********************************************************************/
+
+
+typedef struct cdDbFlag_n {
+ cdms_Id id; /* id identifier */
+ int L_multi; /* size of arrays */
+ int *multi_ioc; /* multi-file ioc's */
+ cdDset_new **multi_ds; /* multi-file 1st var. */
+ FILE *FPT_OUT; /* NULL or ioc of file */
+ int FPT_TTY; /* flag: print to tty */
+ int ERR_no; /* global error flag */
+ char *TempMount; /* tempory mount point */
+ int EDIT_STRUCT_DATA_FLG; /* edit struct or data */
+ int FPT_PY; /* flag: print to python */
+ int qlerrflg; /* flag: 'ql' routines */
+ char *PSQL_MSG; /* message to print */
+ char *PY_PSQL_MSG; /* message to python */
+ int l_PY_PSQL_MSG; /* length of PY_PSQL_MSG */
+ int L_PY_PSQL_MSG; /* size of PY_PSQL_MSG */
+ int l_ALT_PAT; /* length of ALT_PAT */
+ char *ALT_PAT; /* alter replace patern */
+} cdDbFlag;
+
+
+/**********************************************************************/
+ /* Global scalars, arrays, statement functions */
+/**********************************************************************/
+
+
+#ifndef PSQL
+cdDb_new *DB_ROOT_ADR; /* tree root address */
+FILE *FPT_OUT; /* NULL or ioc of file */
+int FPT_TTY; /* flag to print to tty */
+int ERR_no; /* global error flag */
+char *TempMount; /* ascii tempory mount returned by pwd */
+int EDIT_STRUCT_DATA_FLG; /* edit struct or data flag */
+int FPT_PY; /* flag: print to python */
+char *PSQL_MSG; /* psql message to print */
+char *PY_PSQL_MSG; /* psql message to send to python */
+int l_PY_PSQL_MSG; /* length of PY_PSQL_MSG */
+int L_PY_PSQL_MSG; /* size of PY_PSQL_MSG array */
+#else
+extern cdDb_new *DB_ROOT_ADR;
+extern FILE *FPT_OUT;
+extern int FPT_TTY;
+extern int ERR_no;
+extern char *TempMount;
+extern int EDIT_STRUCT_DATA_FLG;
+extern int FPT_PY;
+extern *PSQL_MSG;
+extern *PY_PSQL_MSG;
+extern l_PY_PSQL_MSG;
+extern L_PY_PSQL_MSG;
+#endif
+
+#define pt_to_long(p,l) { void **v; v = (void *) &l; *v = (void *) p; }
+#define long_to_pt(l,p) { void **v; v = (void *) &l, p = *v; }
+#define err_x(a) { err_m(a); ERR_no = 1; return; }
+#define err_t(a,b) { if( a ) err_x(b); }
+#define err_r(void) { if( ERR_no ) return; }
+#define err_i(a) { ERR_no = a; }
+#define qlerr_x(a) { err_m(a); ERR_no = 0; return -1; }
+#define qlerr_r(void) { if( ERR_no ) { ERR_no = 0; return -1; } }
+
+/*.......error macros for functions of type long int.......*/
+#define err_xl(a) { err_m(a); ERR_no = 1; return (long) 0; }
+#define err_rl(void) { if( ERR_no ) return (long) 0; }
+#define err_tl(a,b) { if( a ) err_xl(b); }
+
+/*.......error macros for functions of type void* .......*/
+#define err_xv(a) { err_m(a); ERR_no = 1; return NULL; }
+#define err_rv(void) { if( ERR_no ) return NULL; }
+#define err_tv(a,b) { if( a ) err_xv(b); }
+
+/*.......err macros for functions of type int.......*/
+#define err_xi(a) { err_m(a); ERR_no = 1; return 0; }
+#define err_ri(void) { if( ERR_no ) return 0; }
+#define err_ti(a,b) { if( a ) err_xi(b); }
+
+
+/**********************************************************************/
+ /* Function prototypes */
+/**********************************************************************/
+
+
+/*..........bgn_extern..........*/
+extern void alt_addatt( cdms_card *line,
+ cdHd *hd,
+ int idx,
+ int flg );
+extern void alt_adddim( cdms_card *line,
+ cdHd *hd,
+ int flg );
+extern void alt_addvar( cdms_card *line,
+ cdHd *hd,
+ int flg );
+extern void alt_arg_pat( char *out,
+ char *in );
+extern void alt_att_concat( cdms_card *line,
+ cdHd *hd,
+ int idx );
+extern void alt_delatt( cdms_card *line,
+ cdHd *hd );
+extern void alt_del_node( cdAtt_new *att );
+extern void alter_dataset( cdHd *cur );
+extern void alt_midmonth( cdHd *hd,
+ char *nmod,
+ char *ncal,
+ char *ntim );
+extern void alt_mod_shape( cdAtt_new *att );
+extern void alt_newtim( cdms_card *line,
+ cdDim_new *dim,
+ int idx );
+extern void alt_one_dim( cdDim_new *dim,
+ cdCheck *ck );
+extern void alt_one_ds( cdDset_new *ds,
+ cdCheck *ck );
+extern void alt_one_var( cdVar_new *var,
+ cdCheck *ck );
+extern void alt_tim6h( cdHd *hd,
+ char *nmod,
+ char *ncal,
+ char *ntim );
+extern long alt_values( cdms_card *line,
+ int idx,
+ cdHd *hd,
+ long len );
+extern void alt_wrt_cards( cdDset_new *dset,
+ char *name );
+extern void ary_min_max( cdType typ,
+ long len,
+ void *ary,
+ double *min,
+ double *max );
+extern void *ary_off( cdType typ,
+ long idx,
+ void *ary );
+extern void *ary_trans( cdType typ,
+ long len,
+ void *ary,
+ cdType out_typ );
+extern void att_to_dgv( cdDim_new *dim,
+ cdVar_new *var );
+extern void cdPqltty(void);
+extern void check_dataset( cdHd *cur,
+ int pflg );
+extern int check_filename( char *name );
+extern int ck_lnk_list_att( cdAtt_new *att0,
+ int pflg );
+extern int ck_lnk_list_dim( cdDim_new *dim0,
+ int pflg );
+extern int ck_lnk_list_var( cdVar_new *var0,
+ int pflg );
+extern void ck_nam_fnd( cdms_Id idwant,
+ char name[],
+ char tagname[],
+ int *num,
+ cdCheck ***cklist );
+extern int ck_one_att( cdAtt_new *att0,
+ cdCheck *ck,
+ int pflg );
+extern int ck_one_dim( cdDim_new *dim,
+ cdCheck *ck,
+ int pflg );
+extern int ck_one_var( cdVar_new *var,
+ cdCheck *ck,
+ int pflg );
+extern void *copy_struct( cdHd *cur,
+ cdHd *abv );
+extern char *cr_asc_cpy( char *in );
+extern void cr_att_cpy( cdAtt_new *atta,
+ cdHd *cur );
+extern void *cre_struct( cdms_Id idwant,
+ cdHd *cur );
+extern void delete_struct( cdHd *cur );
+extern int dim_f1( int idx,
+ cdms_card *line,
+ cdDim_new *dim );
+extern int dim_f2( int idx,
+ cdms_card *line,
+ cdDim_new *dim );
+extern int dim_f3( int idx,
+ cdms_card *line,
+ cdDim_new *dim );
+extern void dir_file( cdms_dir *dir,
+ char *path,
+ char *name,
+ cdHd *cur );
+extern void dir_file_dim( cdms_dir *dir,
+ char *path,
+ char *name,
+ int f_id,
+ int f_ndims,
+ cdDset_new *ds );
+extern void dir_file_noscan( cdms_dir *dir,
+ char *path,
+ char *name,
+ cdHd *cur );
+extern cdHd *dir_struct( cdms_dir *dir,
+ char *path,
+ cdHd *hd,
+ int flg );
+extern void dir_to_tree( cdms_dir *dir,
+ int lev,
+ cdHd *cur );
+extern void edit_struct( cdHd *cur );
+extern void edit_struct_att( cdAtt_new *att );
+extern void edit_struct_dim( cdDim_new *dim,
+ int dedit );
+extern void edit_struct_hdr( char name[] );
+extern void edit_struct_num( char name[],
+ cdType typ,
+ long len,
+ void *ary );
+extern void edit_struct_var( cdVar_new *var,
+ int dedit );
+extern void *empty_struct( cdHd *cur );
+extern int ending_quote( char *asc_line,
+ int idx1,
+ int idx2 );
+extern int ending_star( char *asc_line,
+ int idx1,
+ int idx2 );
+extern void err_cdms( char *in,
+ int n );
+extern void err_m( char *msg );
+extern void fnd_dir_list( char ***nam,
+ int **flg,
+ int *num,
+ int scnflg );
+extern void **fnd_lnk_list( cdms_Id idwant,
+ cdHd *cur );
+extern void *get_coord( cdDim_new *dim,
+ cdType typ,
+ long *len );
+extern char *get_cur_dir( void );
+extern char *get_path_of_file( char *filename,
+ char *mpath );
+extern cdDb_new *init_user_db( void );
+extern void ins_asym_eos( cdms_card *line );
+extern void load_ds_arrays( cdDset_new *dset );
+extern void mem_cdms_card( cdms_card **out1 );
+extern void mem_cdms_pql_list( cdms_pql_list **out2 );
+extern cdCheck *mem_check( cdCheck *cka,
+ int ncd,
+ int nal,
+ int nfs );
+extern span_list *mem_span_list( span_list *spa,
+ int nfl,
+ int nsc );
+extern void *mem_struct( cdms_Id idwant,
+ cdHd *cur );
+extern void *meta_after_eq( int idx,
+ cdms_card *line,
+ cdType *typ,
+ long *num );
+extern void *meta_att( cdms_card *line,
+ cdHd *mas );
+extern int meta_str_sym( cdms_card *line,
+ int idx,
+ int len );
+extern void *nam_fnd( char name[],
+ cdms_Id idwant,
+ cdHd *cur );
+extern void *old_att_name( cdHd *cur );
+extern void old_py_name( cdms_card *line );
+extern int pql_alter( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern int pql_check( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern void pql_compress( cdms_pql_list *pql,
+ int idx,
+ cdms_Id idwant );
+extern int pql_dirtree( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern void pql_execute( char msg_ln[] );
+extern int pql_filename( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern cdPql *pql_fld1( cdms_card *line,
+ int idx,
+ int *outidx );
+extern int pql_fld2( cdms_card *line,
+ int idx );
+extern cdHd *pql_fld3( cdms_card *line,
+ int idx,
+ int *outidx );
+extern int pql_fld4( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern int pql_fld5( cdms_card *line,
+ int idx,
+ int *idx_w );
+extern int pql_fld6( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern int pql_gen_list( cdms_card *line,
+ cdms_pql_list *pql,
+ int i2,
+ int i3 );
+extern int pql_group( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern void pql_key_sym( cdms_card *line );
+extern int pql_lenreadbuf( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern void pql_one_level( cdms_pql_list *pql,
+ cdHd *cur );
+extern void pql_one_level_all( cdms_pql_list *pql,
+ cdHd *cur );
+extern void pql_one_mem( cdms_pql_list *pql,
+ int num );
+extern char *pql_rd_line( cdms_card *line,
+ char msg_ln[] );
+extern int pql_read( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern int pql_readalter( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern int pql_readcheck( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern void pql_read_cmp( var_pql_read *rd,
+ void *ary1,
+ void *ary2,
+ cdType typ );
+extern void pql_read_dmem( var_pql_read *rd );
+extern void pql_read_exp( var_pql_read *rd,
+ void *ary1,
+ void *ary2,
+ cdType typ );
+extern void pql_read_fil( var_pql_read *rd );
+extern long *pql_read_idx( var_pql_read *rd );
+extern var_pql_read *pql_read_mem( cdVar_new *var );
+extern int pql_readmeta( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern int pql_read_sec( cdms_card *line,
+ cdms_pql_list *pql,
+ var_pql_read **outrd,
+ int idx );
+extern void pql_read_var( var_pql_read *rd );
+extern void pql_read_wrt( var_pql_read *rd,
+ char *nam );
+extern int pql_release( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern int pql_select( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern int pql_show( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern void pql_show_ary( cdType typ,
+ long len,
+ void *ary );
+extern void pql_show_ed( int cnt,
+ cdms_card *line,
+ int idxl1,
+ int idxl2,
+ int idxl3,
+ cdms_pql_list *pql,
+ int idx1,
+ int idx2 );
+extern int pql_show_sec( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern void pql_show_value( cdms_pql_list *pql,
+ int idx );
+extern int pql_subfgroup( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern void pql_sublist( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx,
+ int idxl1,
+ int idxl2 );
+extern void pql_tree( cdms_pql_list *pql,
+ cdms_Id idwant,
+ int tflg,
+ cdHd *cur );
+extern int pql_union( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern int pql_virtual( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern int pql_where( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern int pql_whr_1test( cdms_pql_list *pql );
+extern int pql_whr_dtest( cdms_pql_list *pql );
+extern int pql_whr_gtest( cdms_pql_list *pql );
+extern int pql_whr_itest( cdms_pql_list *pql );
+extern int pql_whr_ltest( cdms_pql_list *pql );
+extern void pql_whr_node( cdms_pql_list *pql,
+ int idx );
+extern int pql_whr_ntest( cdms_pql_list *pql );
+extern int pql_whr_test( cdms_pql_list *pql,
+ int idx1,
+ int idx2 );
+extern int pql_whr_ttest( cdms_pql_list *pql );
+extern int pql_whr_vtest( cdms_pql_list *pql );
+extern int pql_with( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern int pql_writeds( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern int pql_writemeta( cdms_card *line,
+ cdms_pql_list *pql,
+ int idx );
+extern void pro_data_lines( cdms_card *line,
+ cdHd *mas );
+extern cdDb_new *pro_db_lines( cdms_card *line,
+ cdHd *mas );
+extern void pro_dim_lines( cdms_card *line,
+ cdHd *mas );
+extern cdDset_new *pro_dset_lines( cdms_card *line,
+ cdHd *mas );
+extern void pro_tmp_att( void );
+extern void pro_var_lines( cdms_card *line,
+ cdHd *mas );
+extern char *py_psql_execute( long ldb,
+ char msg_ln[] );
+extern long py_psql_init( void );
+extern int qlattget( int fileid,
+ int varid,
+ char *name,
+ void *values );
+extern int qlattinq( int fileid,
+ int varid,
+ char *name,
+ CuType *datatype,
+ int *len );
+extern int qlattname( int fileid,
+ int varid,
+ int attnum,
+ char *name );
+extern int qlclose( int fileid );
+extern cdDim_new *ql_dim_fnd( int fileid,
+ int varid,
+ int dimid,
+ char *name,
+ int *n_dim );
+extern int qldimget( int fileid,
+ int dimid,
+ void *values );
+extern int qldimid( int fileid,
+ int varid,
+ char *name );
+extern int qldiminq( int fileid,
+ int dimid,
+ char *dimname,
+ char *dimunits,
+ CuType *datatype,
+ CuDimType *dimtype,
+ int *varid,
+ long *length );
+extern int qlinquire( int fileid,
+ int *ndims,
+ int *nvars,
+ int *natts,
+ int *recdim );
+extern int qlintr( char msg_ln[] );
+extern int qlopenread( int fileid,
+ char *controlpath,
+ char *datapath );
+extern int qlseterropts( int err_flg );
+extern cdVar_new *ql_var_fnd( int fileid,
+ int varid,
+ char *name,
+ int *n_var );
+extern int qlvarget( int fileid,
+ int varid,
+ long start[],
+ long count[],
+ void *value );
+extern int qlvarid( int fileid,
+ char *name );
+extern int qlvarinq( int fileid,
+ int varid,
+ char *name,
+ CuType *datatype,
+ int *ndims,
+ int dimids[],
+ int *natts );
+extern void rd_alt_dim_mod( dim_pql_read *rd,
+ char *name );
+extern void rd_alt_dim_tran( dim_pql_read *rd,
+ long *idx );
+extern int rd_alter_file( char *filename );
+extern void rd_alt_var_mod( var_pql_read *rd,
+ char *name );
+extern long *rd_alt_var_ridx( var_pql_read *rd );
+extern long *rd_alt_var_tidx( var_pql_read *rd );
+extern void rd_alt_var_tran( var_pql_read *rd,
+ long *idx );
+extern int rd_check_file( char *filename );
+extern void *rd_dim_array( cdDim_new *dim,
+ long start,
+ long count );
+extern void *rd_dim_coord( dim_pql_read *rd );
+extern int rd_meta_file( char *filename );
+extern int rd_meta_line( cdms_card *line );
+extern void rd_small_dim_card( cdms_card *line,
+ span_list *span );
+extern void rd_small_file( cdms_card *line,
+ char *path,
+ char *fall );
+extern void *rd_var_array( cdVar_new *var,
+ long start[],
+ long count[] );
+extern void rel_cdms_card( cdms_card *line );
+extern void rel_cdms_pql_list( cdms_pql_list *pql );
+extern void rel_check( cdCheck *cka );
+extern void *scn_lnk_list( char name[],
+ cdms_Id idwant,
+ cdHd *cur );
+extern void scn_small_alterf( cdDset_new *ds,
+ char *altf,
+ char *mpath );
+extern void scn_small_db( span_list *span,
+ cdDb_new *db,
+ char *nam,
+ char *pth );
+extern void scn_small_file( cdms_card *line,
+ span_list *span,
+ char *mpath );
+extern char *typ_as_ascii( cdType dtype );
+extern cdType typ_from_ascii( char *aa );
+extern void typ_from_cdunif( CuType dtype,
+ cdType *typ,
+ int *len );
+extern int typ_of_calendar( char *aa );
+extern int typ_time_dim( char *dnam );
+extern void typ_to_cdunif( cdType dtype,
+ CuType *typ,
+ int *len );
+extern void typ_to_netcdf( cdType dtype,
+ nc_type *typ,
+ int *len );
+extern void wrt_ds_to_netcdf( cdDset_new *dset,
+ char *nam,
+ char *tim );
+extern void wrt_msg( void );
+extern void wrt_small_file( cdHd *hd,
+ char *unam );
+/*..........end_extern..........*/
+#endif
diff --git a/include/cdTime/cdrra.h b/include/cdTime/cdrra.h
new file mode 100644
index 0000000..cf747f7
--- /dev/null
+++ b/include/cdTime/cdrra.h
@@ -0,0 +1,43 @@
+/* -*-Mode: C;-*-
+ * Module: cdunif right-ragged array 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$
+ *
+ * Revision History:
+ *
+ * $Log: cdrra.h,v $
+ * Revision 1.1 1994/11/18 23:42:26 drach
+ * Initial version
+ *
+ *
+ */
+
+
+ /* ddi right ragged array declarations */
+#ifndef _DDI_RRA
+#define _DDI_RRA
+
+#include <stddef.h>
+
+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] */
+} DDI_RRA;
+
+ /* Set the ith element of dimension id of a to value */
+#define SETRRA(a,id,i,value) a->indices[id][i]=value
+
+extern DDI_RRA *createRRA(long rank, const long arraySize[], const long dimensionSize[]);
+extern void destroyRRA(DDI_RRA *);
+extern int sortRRA(DDI_RRA *, DDI_RRA *, const long []);
+extern int printRRA(DDI_RRA *);
+#endif
diff --git a/include/cdTime/cdunif.h b/include/cdTime/cdunif.h
new file mode 100644
index 0000000..e7bc676
--- /dev/null
+++ b/include/cdTime/cdunif.h
@@ -0,0 +1,175 @@
+/* -*-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$
+ *
+ * Revision History:
+ *
+ * $Log: cdunif.h,v $
+ * 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 512 /* 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, CuPP=6, 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/include/cdTime/cdunifint.h b/include/cdTime/cdunifint.h
new file mode 100644
index 0000000..8e3bed0
--- /dev/null
+++ b/include/cdTime/cdunifint.h
@@ -0,0 +1,383 @@
+/* -*-Mode: C;-*-
+ * Module: cdunifint.h - cdunif internal 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$
+ *
+ * Revision History:
+ *
+ * $Log: cdunifint.h,v $
+ * Revision 1.2 1998/07/02 23:40:47 drach
+ * - Added support for absolute time, via routines cdAbs2Comp, cdComp2Abs, cdDecodeRelativeTime, and cdDecodeAbsoluteTime
+ * - Added support for the LANL POP ocean data format
+ *
+ * Revision 1.1.1.1 1997/12/09 18:57:39 drach
+ * Copied from cirrus
+ *
+ * Revision 1.15 1997/12/03 22:21:53 drach
+ * - In cdunifdrs.c, dimensions which are reversed or subsetted wrt a
+ * coordinate dimension are now treated as local.
+ * - Added cdDimGetDouble to cdmsslab.c
+ * - Fixed wraparound, reading wraparound dimensions in cdmsslab.c
+ *
+ * Revision 1.14 1997/11/24 17:28:06 drach
+ * - Added QL package to cdunif
+ * - Added NdimIntersect function to CDMS
+ *
+ * Revision 1.13 1997/10/24 18:23:36 drach
+ * - Cache netCDF unlimited dimensions
+ * - Consistent with GrADS src170
+ *
+ * Revision 1.12 1997/09/26 21:45:27 drach
+ * - Added HDF
+ * - Repaired fouled up cddrs includes
+ *
+ * Revision 1.11 1997/01/06 17:47:14 drach
+ * - Added HDF to cdunif
+ *
+ * Revision 1.10 1995/10/16 18:57:20 drach
+ * - Added CuInt datatype, DEC Alpha version
+ * - Modified prototypes for casting routines
+ *
+ * Revision 1.9 1995/09/15 21:18:52 drach
+ * - Modified for Cray
+ *
+ * Revision 1.8 1995/03/09 00:35:19 drach
+ * Added netCDF, upgraded cureadarray with casting, user-specified indices
+ *
+ * Revision 1.7 1995/01/18 02:53:59 drach
+ * - Made cuseterropts a dispatch function
+ *
+ * Revision 1.6 1994/12/20 23:12:46 drach
+ * - Added GrADS function declarations
+ *
+ * Revision 1.5 1994/12/20 01:20:07 drach
+ * - Added copybuffer size define
+ *
+ * Revision 1.4 1994/12/17 00:43:26 drach
+ * - remove cuNextLu extern def - localized in cdunif.c now
+ *
+ * Revision 1.3 1994/12/14 02:33:40 drach
+ * - Renamed _CDUNIFIO_H to _CDUNIFINT_H
+ *
+ * Revision 1.2 1994/11/18 00:12:47 drach
+ * Added error processing routines and externs.
+ *
+ * Revision 1.1 1994/11/17 21:39:13 drach
+ * Initial version
+ *
+ *
+ */
+#ifndef _CDUNIFINT_H
+#define _CDUNIFINT_H
+
+#include <stdlib.h>
+#include "cdunif.h"
+
+/*
+ * =================================================================
+ * Magic cookies
+ * =================================================================
+ */
+#if defined(cray)
+#define DRS_MAGIC_COOKIE 0x4452532044494354
+#define NETCDF_MAGIC_COOKIE 0x4344460100000000
+#define NETCDF4_MAGIC_COOKIE 0x894844460000000
+#define NETCDF4_64BIT_MAGIC_COOKIE 0x460243440000000
+#define NETCDF4_64BIT_MAGIC_COOKIE2 0x444689480000000
+#define HDF_MAGIC_COOKIE 0x0e03130100000000
+#elif defined(__alpha)
+#define DRS_MAGIC_COOKIE 0x5443494420535244
+#define NETCDF_MAGIC_COOKIE 0x0000000001464443
+#define NETCDF4_MAGIC_COOKIE 0x000000046444889
+#define NETCDF4_64BIT_MAGIC_COOKIE 0x000000002464443
+#define NETCDF4_64BIT_MAGIC_COOKIE2 0x0000000046444889
+#define HDF_MAGIC_COOKIE 0x000000000113030e
+#elif defined(__ia64)
+#define DRS_MAGIC_COOKIE 0x5443494420535244
+#define NETCDF_MAGIC_COOKIE 0x0000000001464443
+#define NETCDF4_MAGIC_COOKIE 0x000000046444889
+#define NETCDF4_64BIT_MAGIC_COOKIE 0x000000002464443
+#define NETCDF4_64BIT_MAGIC_COOKIE2 0x000000046444889
+#define HDF_MAGIC_COOKIE 0x000000000113030e
+#elif defined(__x86_64__)
+#define DRS_MAGIC_COOKIE 0x5443494420535244
+#define NETCDF_MAGIC_COOKIE 0x0000000001464443
+#define NETCDF4_MAGIC_COOKIE 0x000000002464443
+#define NETCDF4_64BIT_MAGIC_COOKIE 0x000000002464443
+#define NETCDF4_64BIT_MAGIC_COOKIE2 0x000000046444889
+#define HDF_MAGIC_COOKIE 0x000000000113030e
+#elif defined(BYTESWAP)
+#define DRS_MAGIC_COOKIE 0x20535244
+#define NETCDF_MAGIC_COOKIE 0x01464443
+#define HDF_MAGIC_COOKIE 0x0113030e
+#define NETCDF4_MAGIC_COOKIE 1178880137
+#define NETCDF4_64BIT_MAGIC_COOKIE 0x02464443
+#define NETCDF4_64BIT_MAGIC_COOKIE2 0x46444889
+#else
+#define DRS_MAGIC_COOKIE 0x44525320
+#define NETCDF_MAGIC_COOKIE 0x43444601
+#define HDF_MAGIC_COOKIE 0x0e031301
+#define NETCDF4_MAGIC_COOKIE -1991752634
+#define NETCDF4_64BIT_MAGIC_COOKIE 0x46024344
+#define NETCDF4_64BIT_MAGIC_COOKIE2 0x44468948
+#endif
+
+#define CU_BUFSIZE 204800 /* Size of cureadarray copy buffer, in bytes */
+/*
+ * =================================================================
+ * Structures
+ * =================================================================
+ */
+
+typedef struct cu_file CuFile;
+typedef struct cu_var CuVar;
+typedef struct cu_dim CuDim;
+typedef struct cu_att CuAtt;
+
+struct cu_att { /* Attribute */
+ char name[CU_MAX_NAME+1]; /* Attribute name */
+ CuType datatype; /* Datatype of the attribute */
+ long len; /* Number of elements (NOT bytes) */
+ void *val; /* Pointer to internal structure for GrADS */
+};
+
+struct cu_dim { /* Dimension */
+ char name[CU_MAX_NAME+1]; /* Dimension name */
+ char units[CU_MAX_NAME+1]; /* Dimension units */
+ CuVar* var; /* Variable for local dimensions; (CuVar*)0 for global */
+ CuVar* coord; /* Associated coordinate variable if global, or (CuVar*)0 if local */
+ int internid; /* Internal integer ID (0-origin dimension number for DRS) */
+ int spacing; /* For DRS, IDRS_EQUALLY_SPACED or IDRS_UNEQUALLY_SPACED */
+ double first; /* First dimension value, for DRS eq-spaced dimensions, or first coordinate value for DRS uneq-spaced dimensions */
+ double interval; /* Dimension interval for DRS eq-spaced dimensions */
+ void *internp; /* Pointer to internal structure for GrADS */
+ long len; /* Number of elements (NOT bytes) */
+ CuType datatype; /* Datatype of related coordinate dimension, or CuDouble if none */
+ CuDimType dimtype; /* Type of dimensions (CuGlobalDim or CuLocalDim) */
+};
+
+struct cu_var { /* Variable */
+ int id; /* Cdunif ID */
+ char name[CU_MAX_NAME+1]; /* Variable name */
+ CuFile *file; /* File containing this variable */
+ int internalid; /* Internal ID (e.g., for netCDF) */
+ void *internp; /* Pointer to internal structure for GrADS */
+ CuType datatype; /* Datatype of variable */
+ int ndims; /* Number of dimensions */
+ int dims[CU_MAX_VAR_DIMS]; /* Pointer to array of dimension IDs */
+ int natts; /* Number of attributes for this variable */
+ CuAtt *atts; /* Pointer to array of attributes */
+};
+
+struct cu_file { /* File */
+ char controlpath[CU_MAX_PATH+1]; /* Pathname of control file */
+ char datapath[CU_MAX_PATH+1]; /* Pathname of datafile (e.g., for DRS) */
+ int id; /* Cdunif ID */
+ int internid1; /* First internal ID (e.g. dictionary LU for DRS); netCDF file ID */
+ int internid2; /* Second internal ID (e.g., datafile LU for DRS) */
+ void *internp; /* Pointer to internal structure for GrADS */
+ CuFileType filetype; /* File format */
+ int ndims; /* Total number of global AND local dimensions */
+ CuDim* dims; /* Pointer to array of global and local dimensions */
+ int recdim; /* Record dimension, or -1 if not applicable */
+ void *recdimcache; /* Record dimension cached values, or 0 if no values */
+ int nvars; /* Number of variables */
+ CuVar* vars; /* Pointer to array of variables */
+ int ngatts; /* Number of global attributes */
+ CuAtt* atts; /* Pointer to array of global attributes */
+ CuFile* next; /* Next file in list */
+};
+
+/*
+ * =================================================================
+ * Function prototypes
+ * =================================================================
+ */
+ /* cdunif internal functions */
+extern CuFile* CuCreateFile(CuFileType filetype);
+extern CuFile* CuLookupFile(int fileid);
+extern int CuDeleteFile(int fileid);
+extern CuVar* CuCreateVars(CuFile* file, int nvars);
+extern CuVar* CuLookupVar(CuFile* file, int varid);
+extern int CuDeleteVars(CuFile* file);
+extern CuDim* CuCreateDims(CuFile* file, int ndims);
+extern CuDim* CuLookupDim(CuFile* file, int dimid);
+extern CuAtt* CuCreateAtts(CuFile* file, CuVar* var, int natts);
+extern int CuSetAtt(CuFile* file, CuVar* var, int attnum, const char *name, CuType datatype, long len, void *values);
+extern CuAtt* CuLookupAtt(CuFile* file, int varid, const char *name);
+extern int CuDeleteAtts(CuFile* file, CuVar *var);
+extern CuFileType CuGetFileType(const char *controlpath);
+extern void CuError(int ierr, char *fmt, ...);
+
+ /* cureadarray internal functions */
+extern int cuCopyArray(char *a, CuRRA *aIndices, char *b, CuRRA *bIndices, const long transpose[], size_t elemSize);
+extern int cureadarray1(int fileid, int varid, CuRRA *vIndices, const long transpose[], void *userArray,
+ CuRRA *uIndices, void *copyBuffer, long lenBuffer, long iter);
+extern int cuCast(CuType fromType, CuType toType, long nelems, void *array);
+extern void cuFloat2Double(long nelems, void *buf);
+extern void cuDouble2LongDouble(long nelems, void *buf);
+extern void cuChar2Short(long nelems, void *buf);
+extern void cuShort2Int(long nelems, void *buf);
+extern void cuInt2Long(long nelems, void *buf);
+extern void cuDouble2Float(long nelems, void *buf);
+extern void cuLongDouble2Double(long nelems, void *buf);
+extern void cuShort2Char(long nelems, void *buf);
+extern void cuInt2Short(long nelems, void *buf);
+extern void cuLong2Int(long nelems, void *buf);
+
+ /* Stub functions */
+extern int cuclose_stub(CuFile* file);
+extern int cuinquire_stub(CuFile* file, int* ngdims, int* nvars, int* natts, int* recdim);
+extern int cudimid_stub(CuFile* file, int varid, const char* name);
+extern int cudiminq_stub(CuFile* file, int dimid, char* dimname, char* dimunits, CuType* dataType, CuDimType* dimtype, int* varid, long* length);
+extern int cudimget_stub(CuFile* file, int dimid, void* values);
+extern int cuvarid_stub(CuFile* file, const char* name);
+extern int cuvarinq_stub(CuFile* file, int varid, char* name, CuType* datatype, int* ndims, int dimids[], int* natts);
+extern int cuvarget_stub(CuFile* file, int varid, const long start[], const long count[], void* value);
+extern int cuattinq_stub(CuFile* file, int varid, const char* name, CuType* datatype, int* len);
+extern int cuattget_stub(CuFile* file, int varid, const char* name, void* value);
+extern int cuattname_stub(CuFile* file, int varid, int attnum, char* name);
+
+ /* Generic functions use cdunifint structures built at */
+ /* file open, can be used for any format which builds */
+ /* the proper structures */
+extern int cuinquire_gen(CuFile* file, int* ngdims, int* nvars, int* natts, int* recdim);
+extern int cudimid_gen(CuFile* file, int varid, const char* name);
+extern int cudiminq_gen(CuFile* file, int dimid, char* dimname, char* dimunits, CuType* dataType, CuDimType* dimtype, int* varid, long* length);
+extern int cuvarid_gen(CuFile* file, const char* name);
+extern int cuvarinq_gen(CuFile* file, int varid, char* name, CuType* datatype, int* ndims, int dimids[], int* natts);
+extern int cuattinq_gen(CuFile* file, int varid, const char* name, CuType* datatype, int* len);
+extern int cuattget_gen(CuFile* file, int varid, const char* name, void* value);
+extern int cuattname_gen(CuFile* file, int varid, int attnum, char* name);
+extern void cuseterropts_gen(int erropts);
+
+ /* DRS functions */
+#ifdef drs
+extern int cuopenread_drs(const char* controlpath, const char* datapath);
+extern int cuclose_drs(CuFile* file);
+extern int cudimget_drs(CuFile* file, int dimid, void* values);
+extern int cuvarget_drs(CuFile* file, int varid, const long start[], const long count[], void* value);
+extern void cuseterropts_drs(int erropts);
+extern char* custrtrim(char* s);
+#else
+extern int cuopenread_stub_drs(const char* controlpath, const char* datapath);
+#endif
+
+ /* GrADS functions */
+#ifdef grads
+extern int cuopenread_grads(const char* controlpath, const char* datapath);
+extern int cuclose_grads(CuFile* file);
+extern int cudimget_grads(CuFile* file, int dimid, void* value);
+extern int cuvarget_grads(CuFile* file, int varid, const long start[], const long count[], void* value);
+#else
+extern int cuopenread_stub_grads(const char* controlpath, const char* datapath);
+#endif
+
+ /* netCDF functions */
+#ifdef netcdf
+#include "netcdf.h"
+extern int cuopenread_nc(const char* controlpath, const char* datapath);
+extern int cuclose_nc(CuFile* file);
+extern int cuinquire_nc(CuFile* file, int* ngdims, int* nvars, int* natts, int* recdim);
+extern int cudimid_nc(CuFile* file, int varid, const char* name);
+extern int cudiminq_nc(CuFile* file, int dimid, char* dimname, char* dimunits, CuType* dataType, CuDimType* dimtype, int* varid, long* length);
+extern int cudimget_nc(CuFile* file, int dimid, void* values);
+extern int cuvarid_nc(CuFile* file, const char* name);
+extern int cuvarinq_nc(CuFile* file, int varid, char* name, CuType* datatype, int* ndims, int dimids[], int* natts);
+extern int cuvarget_nc(CuFile* file, int varid, const long start[], const long count[], void* value);
+extern int cuattinq_nc(CuFile* file, int varid, const char* name, CuType* datatype, int* len);
+extern int cuattget_nc(CuFile* file, int varid, const char* name, void* value);
+extern int cuattname_nc(CuFile* file, int varid, int attnum, char* name);
+extern void cuseterropts_nc(int erropts);
+extern void cumapdatatype_nc(nc_type nctype, CuType* cutype);
+extern int cugetattany_nc(CuFile* file, int varid, const char *name, CuType xtype, void *data);
+#else
+extern int cuopenread_stub_nc(const char* controlpath, const char* datapath);
+#endif
+
+ /* HDF functions */
+#ifdef hdf
+#include "hdfi.h"
+typedef int32 hdf_type;
+extern int cuopenread_hdf(const char* controlpath, const char* datapath);
+extern int cuclose_hdf(CuFile* file);
+extern int cuinquire_hdf(CuFile* file, int* ngdims, int* nvars, int* natts, int* recdim);
+extern int cudimid_hdf(CuFile* file, int varid, const char* name);
+extern int cudiminq_hdf(CuFile* file, int dimid, char* dimname, char* dimunits, CuType* dataType, CuDimType* dimtype, int* varid, long* length);
+extern int cudimget_hdf(CuFile* file, int dimid, void* values);
+extern int cuvarid_hdf(CuFile* file, const char* name);
+extern int cuvarinq_hdf(CuFile* file, int varid, char* name, CuType* datatype, int* ndims, int dimids[], int* natts);
+extern int cuvarget_hdf(CuFile* file, int varid, const long start[], const long count[], void* value);
+extern int cuattinq_hdf(CuFile* file, int varid, const char* name, CuType* datatype, int* len);
+extern int cuattget_hdf(CuFile* file, int varid, const char* name, void* value);
+extern int cuattname_hdf(CuFile* file, int varid, int attnum, char* name);
+extern void cuseterropts_hdf(int erropts);
+extern void cuerrorreport_hdf(/* NO ARGS */);
+extern void cumapdatatype_hdf(hdf_type nctype, CuType* cutype);
+#else
+extern int cuopenread_stub_hdf(const char* controlpath, const char* datapath);
+#endif
+
+ /* QL functions */
+#ifdef HAVE_QL
+extern int cuopenread_ql(const char* controlpath, const char* datapath);
+extern int cuclose_ql(CuFile* file);
+extern int cuinquire_ql(CuFile* file, int* ngdims, int* nvars, int* natts, int* recdim);
+extern int cudimid_ql(CuFile* file, int varid, const char* name);
+extern int cudiminq_ql(CuFile* file, int dimid, char* dimname, char* dimunits, CuType* dataType, CuDimType* dimtype, int* varid, long* length);
+extern int cudimget_ql(CuFile* file, int dimid, void* values);
+extern int cuvarid_ql(CuFile* file, const char* name);
+extern int cuvarinq_ql(CuFile* file, int varid, char* name, CuType* datatype, int* ndims, int dimids[], int* natts);
+extern int cuvarget_ql(CuFile* file, int varid, const long start[], const long count[], void* value);
+extern int cuattinq_ql(CuFile* file, int varid, const char* name, CuType* datatype, int* len);
+extern int cuattget_ql(CuFile* file, int varid, const char* name, void* value);
+extern int cuattname_ql(CuFile* file, int varid, int attnum, char* name);
+extern void cuseterropts_ql(int erropts);
+#else
+extern int cuopenread_stub_ql(const char* controlpath, const char* datapath);
+#endif
+
+ /* POP functions */
+#ifdef HAVE_POP
+#include "apic.h"
+extern int cuopenread_pop(const char* controlpath, const char* datapath);
+extern int cuclose_pop(CuFile* file);
+extern int cuinquire_pop(CuFile* file, int* ngdims, int* nvars, int* natts, int* recdim);
+extern int cudimid_pop(CuFile* file, int varid, const char* name);
+extern int cudiminq_pop(CuFile* file, int dimid, char* dimname, char* dimunits, CuType* dataType, CuDimType* dimtype, int* varid, long* length);
+extern int cudimget_pop(CuFile* file, int dimid, void* values);
+extern int cuvarid_pop(CuFile* file, const char* name);
+extern int cuvarinq_pop(CuFile* file, int varid, char* name, CuType* datatype, int* ndims, int dimids[], int* natts);
+extern int cuvarget_pop(CuFile* file, int varid, const long start[], const long count[], void* value);
+extern int cuattinq_pop(CuFile* file, int varid, const char* name, CuType* datatype, int* len);
+extern int cuattget_pop(CuFile* file, int varid, const char* name, void* value);
+extern int cuattname_pop(CuFile* file, int varid, int attnum, char* name);
+extern void cuseterropts_pop(int erropts);
+extern void cumapdatatype_pop(Type nctype, CuType* cutype);
+#else
+extern int cuopenread_stub_pop(const char* controlpath, const char* datapath);
+#endif
+
+ /* PP functions */
+#ifdef HAVE_PP
+extern int cuopenread_pp(const char* controlpath, const char* datapath);
+extern int cuclose_pp(CuFile* file);
+extern int cudimget_pp(CuFile* file, int dimid, void* values);
+extern int cuvarget_pp(CuFile* file, int varid, const long start[], const long count[], void* value);
+#else
+extern int cuopenread_stub_pp(const char* controlpath, const char* datapath);
+#endif
+
+ /* Globals */
+
+extern int cuLastDrsErr; /* Most recent DRS error number */
+extern int cuLastError; /* Most recent cdunif error */
+
+#endif
diff --git a/include/cdTime/cdunifpp/cdunifpp.h b/include/cdTime/cdunifpp/cdunifpp.h
new file mode 100644
index 0000000..6655820
--- /dev/null
+++ b/include/cdTime/cdunifpp/cdunifpp.h
@@ -0,0 +1,1086 @@
+/*
+ *
+ * Copyright (C) 2004-2006 NERC DataGrid
+ * This software may be distributed under the terms of the
+ * CCLRC Licence for CCLRC Software
+ * <CDATDIR>/External_License/CCLRC_CDAT_License.txt
+ *
+ */
+/* Header file for stuff used internally by cdunif_pp */
+
+
+/* all the headers we use */
+#include "cdunif.h"
+#include "cdunifint.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <time.h>
+#include <ctype.h>
+#include <unistd.h>
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+/*---------------------------------------------------------*/
+
+#define CDUNIFPP_VERSION "0.13"
+
+/*---------------------------------------------------------*/
+
+/* Data types for internal calculations:
+ *
+ * NOTE: Fint and Freal must be the same length as each other
+ * and inttype and realtype must be set accordingly
+ *
+ * Currently, this *must* be four-byte, because there is NO CuType
+ * corresponding to 8-byte integer on Linux/gcc (would need to be
+ * long long, but CuLong corresponds to a long)
+ * sizes: int = 4, long = 4, long long = 8
+ *
+ */
+
+typedef int Fint;
+typedef float Freal;
+
+static const CuType inttype = CuInt;
+static const CuType realtype = CuFloat;
+
+static const int wordsize = sizeof(Fint);
+
+/* for float comparisons - related to word size */
+static const float tolerance = 1e-4;
+
+
+/* data types of exact length -- may need to change according to platform
+ * (these are double-checked at run-time in pp_check_sizes()
+ */
+
+typedef int Fint4;
+typedef long long Fint8;
+typedef float Freal4;
+typedef double Freal8;
+
+/*---------------------------------------------------------*/
+
+/* endian-ness - set or clear LITTLE_ENDIAN_MACHINE *
+ * currently seems that BYTESWAP is set for us, so use that,
+ * but could change to include endian.h and then
+ * test using #if (__BYTE_ORDER == __LITTLE_ENDIAN)
+ */
+#ifdef BYTESWAP
+#define LITTLE_ENDIAN_MACHINE
+#else
+#undef LITTLE_ENDIAN_MACHINE
+#endif
+
+/*---------------------------------------------------------*/
+
+/*longest string attribute value */
+#define MAX_ATT_LEN 120
+
+/*---------------------------------------------------------*/
+
+/* Define the following symbol if you want to read in the half-level
+ * values and use them in pp_compare_levels() as extra conditions
+ * for two levels to match. (Grep the code for BDY_LEVS for details.)
+ *
+ * Currently undefined, as if these have *not* been set consistently
+ * in the header, this could cause more problems than it solves. In
+ * particular, BULEV and BHULEV header elements were still BRSVD1 and
+ * BRSVD2 ("reserved for future use") at UM vn 4.5.
+ */
+
+/* #define BDY_LEVS */
+
+
+/*---------------------------------------------------------*/
+
+/* constants */
+
+static const int n_int_hdr = 45;
+static const int n_real_hdr = 19;
+/* static const int n_hdr = n_int_hdr + n_real_hdr; */
+static const int n_hdr = 64;
+
+/* int_fill_value is output */
+static const int int_fill_value = -32768;
+
+/* int_missing_data is convention in input file */
+static const int int_missing_data = -32768;
+
+static const Freal reference_pressure = 1e5; /* Pa */
+
+/* origin time */
+static const int default_year_orig = 1970;
+static const int default_month_orig = 1;
+static const int default_day_orig = 1;
+static const int default_hour_orig = 0;
+static const int default_minute_orig = 0;
+static const int default_second_orig = 0;
+
+static const Freal lon_modulo=360.;
+
+static const Freal pressure_scaling=100.; /* hPa to Pa */
+
+
+/*---------------------------------------------------------*/
+
+/* first, for convenience, typedefs for all the structs */
+typedef struct pp_file PPfile;
+typedef struct pp_var PPvar;
+typedef struct pp_dim PPdim;
+typedef struct pp_rec PPrec;
+typedef struct pp_hdr PPhdr;
+typedef struct pp_stashmeta PPstashmeta;
+typedef struct pp_dimnames PPdimnames;
+typedef struct pp_data PPdata;
+typedef struct pp_list PPlist;
+typedef struct pp_listel PPlistel;
+typedef struct pp_listhandle PPlisthandle;
+
+typedef struct pp_fieldvar PPfieldvar;
+typedef struct pp_genaxis PPgenaxis;
+typedef struct pp_regaxis PPregaxis;
+typedef struct pp_rotgrid PProtgrid;
+typedef struct pp_rotmap PProtmap;
+typedef struct pp_zaxis PPzaxis;
+typedef struct pp_level PPlevel;
+typedef struct pp_taxis PPtaxis;
+typedef struct pp_time PPtime;
+typedef struct pp_xsaxis PPxsaxis;
+typedef struct pp_date PPdate;
+typedef struct pp_landmask PPlandmask;
+typedef struct pp_extra PPextra;
+
+/* similar typedefs for enums are below */
+
+enum pp_calendartype {
+ gregorian,
+ cal360day,
+ model
+};
+
+enum pp_filetype {
+ pp_type,
+ um_type
+};
+
+enum pp_convert {
+ convert_none,
+ convert_int,
+ convert_real
+};
+
+enum pp_axistype {
+ xaxistype,
+ yaxistype,
+ zaxistype,
+ taxistype,
+ num_axistype
+};
+
+enum pp_axisgentype {
+ regaxis_type,
+ zaxis_type,
+ taxis_type,
+ xsaxis_type
+}; /* JAK 2005-01-5 */
+
+enum pp_axisregtype {
+ xregtype,
+ yregtype
+};
+
+enum pp_lev_type {
+ pseudo_lev_type,
+ height_lev_type,
+ depth_lev_type,
+ hybrid_sigmap_lev_type,
+ hybrid_height_lev_type,
+ pressure_lev_type,
+ soil_lev_type,
+ boundary_layer_top_lev_type,
+ top_of_atmos_lev_type,
+ mean_sea_lev_type,
+ surface_lev_type,
+ tropopause_lev_type,
+ other_lev_type
+};
+
+enum pp_lev_val_type {
+ lev_type,
+ hybrid_sigmap_a_type,
+ hybrid_sigmap_b_type,
+ hybrid_height_a_type,
+ hybrid_height_b_type
+};
+
+enum pp_dir {
+ xdir,
+ ydir,
+ zdir,
+ tdir
+};
+
+enum pp_extra_vec {
+ extra_x=1,
+ extra_y=2,
+ extra_title=10
+};
+
+typedef enum pp_convert PPconvert;
+typedef enum pp_filetype PPfiletype;
+typedef enum pp_axistype PPaxistype;
+typedef enum pp_lev_type PPlevtype;
+typedef enum pp_lev_val_type PPlevvaltype;
+typedef enum pp_calendartype PPcalendartype;
+typedef enum pp_axisgentype PPaxisgentype; /* JAK 2005-01-05 */
+typedef enum pp_axisregtype PPaxisregtype;
+typedef enum pp_dir PPdir;
+typedef enum pp_extra_vec PPextravec;
+
+/* Structures for all sorts of things. */
+
+/* (In the rare case where structures are included in another directly,
+ * not as a pointer, need to be defined in correct order. This currently
+ * only affects struct pp_date)
+ */
+
+/* --- these three are internal structures we will hang off the internp
+ * elements of CuFile, CuVar, CuDim
+ */
+struct pp_file {
+ FILE *fh; /* stdio FILE handle */
+ int nrec; /* number of PP records */
+ PPrec **recs; /* records */
+ PPlist *heaplist; /* heap memory */
+ PPfiletype type; /* PP or UM */
+ int swap; /* true if byte swap */
+ int wordsize; /* in bytes */
+ PPlandmask *landmask;
+};
+struct pp_var {
+ int firstrecno; /* for fieldvar */
+ int lastrecno; /* for fieldvar */
+ PPdata *data; /* for dim var */
+
+ PPlist *atts; /* temporary place to store attributes
+ * until the number is known and they can be
+ * added properly
+ */
+};
+
+/*
+ * struct pp_dim {
+ * };
+ */
+
+/*------------------------------------------------------*/
+
+/* metadata which is not contained in the header but looked up
+ * as a function of the stash codes
+ */
+#define SM_MAX_LEN MAX_ATT_LEN
+struct pp_stashmeta {
+ char longname[SM_MAX_LEN+1];
+ char units[SM_MAX_LEN+1];
+ char shortname[SM_MAX_LEN+1];
+ char stdname[SM_MAX_LEN+1];
+
+ /* "source" is where the lookup comes from.
+ *
+ * Quite deliberately there is only one "source", rather than separate sources
+ * for the various names and units (even though the STASHmaster file has long
+ * name but not units in a usable form). These have to go together. It is
+ * no good using a STASHmaster file to override some diagnostics and then using
+ * compiled-in units lookup. Therefore the means of overriding the lookup
+ * with table-driven input is going to have to be something better than
+ * STASHmaster files.
+ */
+ char source[SM_MAX_LEN+1];
+};
+
+/* dimension names (for setting cell methods) */
+struct pp_dimnames {
+ /* we will not be modifying these strings, so declare as const
+ * in order to copy in pointers that are declared const without warnings
+ */
+ const char *x;
+ const char *y;
+ const char *z;
+ const char *t;
+};
+
+/* structure for temporary use while scanning fieldvars */
+struct pp_fieldvar {
+ int firstrecno; /* first record number */
+ int lastrecno; /* last record number */
+ PPrec *firstrec; /* first record */
+ PPlist *axes; /* JAK 2005-01-05 */
+ PProtgrid *rotgrid; /* link to rotated grid, which will
+ * be used for CF "coordinates" stuff
+ */
+ PPdimnames dim_names;
+ PPstashmeta stashmeta;
+ PPhdr *first_header;
+};
+
+
+struct pp_data {
+ CuType type;
+ int n;
+ void *values;
+};
+
+/* for linked list */
+struct pp_list {
+ int n;
+ PPlistel *first;
+ PPlistel *last;
+};
+
+struct pp_listel {
+ void *ptr;
+ PPlistel *prev;
+ PPlistel *next;
+};
+
+struct pp_listhandle {
+ /* This is a little structure which stores the information needed for pp_list_walk.
+ * Its main purpose is to store the position outside the list structure itself,
+ * so that for read-only scanning of the list, the PPlist* can be declared
+ * as const.
+ */
+ PPlistel *current;
+ const PPlist *list;
+};
+
+/* land mask */
+struct pp_landmask {
+ PPgenaxis *xaxis;
+ PPgenaxis *yaxis;
+ PPdata *data;
+};
+
+struct pp_genaxis { /* JAK 2005-01-04 */
+ int dimid;
+ PPaxisgentype gentype;
+ PPdir dir;
+ void *axis;
+};
+
+struct pp_rotmap {
+ Freal pole_lon;
+ Freal pole_lat;
+ Freal truepole_gridlon;
+ CuVar *map_var;
+ char name[CU_MAX_NAME+1];
+};
+
+
+struct pp_rotgrid {
+ /* A rotated grid consists of a mapping and actual x and y values
+ *
+ * Very typically, a mesoscale file will contain only a single mapping
+ * but will contain u and p grids with this mapping. These two grids
+ * will need separate lon,lat coordinate variables.
+ */
+ PProtmap *rotmap;
+ PPgenaxis *xaxis;
+ PPgenaxis *yaxis;
+ char coords[MAX_ATT_LEN+1];
+};
+
+
+/* NON_ROTATED is a pointer value which can be set to imply that an axis
+ * is not rotated, which is non-zero but will not match any real-life memory
+ * location, so that pp_get_rotmap() can return it for a non-rotated axis,
+ * while returning NULL for a problem such as unable to allocate memory
+ */
+
+#define NON_ROTATED ((PProtmap *) 1)
+
+/* and analogously... */
+
+#define NON_ROTATED_GRID ((PProtgrid *) 1)
+
+
+/* regaxis used for x or y axes */
+struct pp_regaxis {
+ int dimid;
+ PPaxisregtype type;
+ Fint n;
+ Freal start;
+ Freal interval;
+ PProtmap *rotmap;
+};
+
+/* zaxis: on reading in a vertical axis, we will ASAP set pp_lev_type to correct
+ * type (see the enum above) by calling pp_level_type(). All tests should ideally
+ * be done on pp_lev_type. Additionally we store lbvc which is a copy of the level
+ * code in the header, for use "in extremis", but really lbvc should not be used
+ * outside of pp_zaxis_set() and pp_level_type() itself, so if you are looking for
+ * something to fix then grep the code for other instances of lbvc...
+ */
+
+struct pp_zaxis {
+ int dimid;
+ PPlevtype lev_type;
+ Fint lbvc;
+ PPlist *values;
+};
+
+struct pp_level {
+ PPlevtype type;
+
+ union {
+
+ struct {
+ Freal level;
+#ifdef BDY_LEVS
+ Freal ubdy_level;
+ Freal lbdy_level;
+#endif
+ } misc;
+
+ struct {
+ Freal a;
+ Freal b;
+#ifdef BDY_LEVS
+ Freal ubdy_a;
+ Freal ubdy_b;
+ Freal lbdy_a;
+ Freal lbdy_b;
+#endif
+ } hybrid_sigmap;
+
+ struct {
+ Freal a;
+ Freal b;
+#ifdef BDY_LEVS
+ Freal ubdy_a;
+ Freal ubdy_b;
+ Freal lbdy_a;
+ Freal lbdy_b;
+#endif
+ } hybrid_height;
+
+ struct {
+ Fint index;
+ } pseudo;
+
+ } values;
+};
+
+struct pp_date {
+ /* this is a generic date */
+ Fint year;
+ Fint month;
+ Fint day;
+ Fint hour;
+ Fint minute;
+ Fint second;
+};
+
+struct pp_taxis {
+ int dimid;
+ Fint type;
+ PPlist *values;
+ PPdate time_orig;
+};
+
+struct pp_time {
+ /* this is a value on time axis */
+ Fint type;
+ PPdate time1;
+ PPdate time2;
+};
+
+struct pp_xsaxis { /* could be pp cross section? */
+ Fint axiscode;
+ PPdata *data;
+};
+
+/* These #defines control which of the PP header elements are to be stored in memory.
+ * To reduce memory use, comment out the ones which are not required.
+ * If you comment out one which is needed, the error should be at compile time.
+ */
+
+#define PP_STORE_LBYR
+#define PP_STORE_LBMON
+#define PP_STORE_LBDAT
+#define PP_STORE_LBHR
+#define PP_STORE_LBMIN
+#define PP_STORE_LBDAY
+#define PP_STORE_LBYRD
+#define PP_STORE_LBMOND
+#define PP_STORE_LBDATD
+#define PP_STORE_LBHRD
+#define PP_STORE_LBMIND
+#define PP_STORE_LBDAYD
+#define PP_STORE_LBTIM
+#define PP_STORE_LBFT
+#define PP_STORE_LBLREC
+#define PP_STORE_LBCODE
+#define PP_STORE_LBHEM
+#define PP_STORE_LBROW
+#define PP_STORE_LBNPT
+#define PP_STORE_LBEXT
+#define PP_STORE_LBPACK
+#define PP_STORE_LBREL
+#define PP_STORE_LBFC
+#define PP_STORE_LBCFC
+#define PP_STORE_LBPROC
+#define PP_STORE_LBVC
+#define PP_STORE_LBRVC
+#define PP_STORE_LBEXP
+#define PP_STORE_LBBEGIN
+#define PP_STORE_LBNREC
+#define PP_STORE_LBPROJ
+#define PP_STORE_LBTYP
+#define PP_STORE_LBLEV
+#define PP_STORE_LBRSVD1
+#define PP_STORE_LBRSVD2
+#define PP_STORE_LBRSVD3
+#define PP_STORE_LBRSVD4
+#define PP_STORE_LBSRCE
+#define PP_STORE_LBUSER1
+#define PP_STORE_LBUSER2
+#define PP_STORE_LBUSER3
+#define PP_STORE_LBUSER4
+#define PP_STORE_LBUSER5
+#define PP_STORE_LBUSER6
+#define PP_STORE_LBUSER7
+#define PP_STORE_BULEV
+#define PP_STORE_BHULEV
+#define PP_STORE_BRSVD3
+#define PP_STORE_BRSVD4
+#define PP_STORE_BDATUM
+#define PP_STORE_BACC
+#define PP_STORE_BLEV
+#define PP_STORE_BRLEV
+#define PP_STORE_BHLEV
+#define PP_STORE_BHRLEV
+#define PP_STORE_BPLAT
+#define PP_STORE_BPLON
+#define PP_STORE_BGOR
+#define PP_STORE_BZY
+#define PP_STORE_BDY
+#define PP_STORE_BZX
+#define PP_STORE_BDX
+#define PP_STORE_BMDI
+#define PP_STORE_BMKS
+
+
+struct pp_hdr {
+#ifdef PP_STORE_LBYR
+ Fint LBYR;
+#endif
+#ifdef PP_STORE_LBMON
+ Fint LBMON;
+#endif
+#ifdef PP_STORE_LBDAT
+ Fint LBDAT;
+#endif
+#ifdef PP_STORE_LBHR
+ Fint LBHR;
+#endif
+#ifdef PP_STORE_LBMIN
+ Fint LBMIN;
+#endif
+#ifdef PP_STORE_LBDAY
+ Fint LBDAY;
+#endif
+#ifdef PP_STORE_LBYRD
+ Fint LBYRD;
+#endif
+#ifdef PP_STORE_LBMOND
+ Fint LBMOND;
+#endif
+#ifdef PP_STORE_LBDATD
+ Fint LBDATD;
+#endif
+#ifdef PP_STORE_LBHRD
+ Fint LBHRD;
+#endif
+#ifdef PP_STORE_LBMIND
+ Fint LBMIND;
+#endif
+#ifdef PP_STORE_LBDAYD
+ Fint LBDAYD;
+#endif
+#ifdef PP_STORE_LBTIM
+ Fint LBTIM;
+#endif
+#ifdef PP_STORE_LBFT
+ Fint LBFT;
+#endif
+#ifdef PP_STORE_LBLREC
+ Fint LBLREC;
+#endif
+#ifdef PP_STORE_LBCODE
+ Fint LBCODE;
+#endif
+#ifdef PP_STORE_LBHEM
+ Fint LBHEM;
+#endif
+#ifdef PP_STORE_LBROW
+ Fint LBROW;
+#endif
+#ifdef PP_STORE_LBNPT
+ Fint LBNPT;
+#endif
+#ifdef PP_STORE_LBEXT
+ Fint LBEXT;
+#endif
+#ifdef PP_STORE_LBPACK
+ Fint LBPACK;
+#endif
+#ifdef PP_STORE_LBREL
+ Fint LBREL;
+#endif
+#ifdef PP_STORE_LBFC
+ Fint LBFC;
+#endif
+#ifdef PP_STORE_LBCFC
+ Fint LBCFC;
+#endif
+#ifdef PP_STORE_LBPROC
+ Fint LBPROC;
+#endif
+#ifdef PP_STORE_LBVC
+ Fint LBVC;
+#endif
+#ifdef PP_STORE_LBRVC
+ Fint LBRVC;
+#endif
+#ifdef PP_STORE_LBEXP
+ Fint LBEXP;
+#endif
+#ifdef PP_STORE_LBBEGIN
+ Fint LBBEGIN;
+#endif
+#ifdef PP_STORE_LBNREC
+ Fint LBNREC;
+#endif
+#ifdef PP_STORE_LBPROJ
+ Fint LBPROJ;
+#endif
+#ifdef PP_STORE_LBTYP
+ Fint LBTYP;
+#endif
+#ifdef PP_STORE_LBLEV
+ Fint LBLEV;
+#endif
+#ifdef PP_STORE_LBRSVD1
+ Fint LBRSVD1;
+#endif
+#ifdef PP_STORE_LBRSVD2
+ Fint LBRSVD2;
+#endif
+#ifdef PP_STORE_LBRSVD3
+ Fint LBRSVD3;
+#endif
+#ifdef PP_STORE_LBRSVD4
+ Fint LBRSVD4;
+#endif
+#ifdef PP_STORE_LBSRCE
+ Fint LBSRCE;
+#endif
+#ifdef PP_STORE_LBUSER1
+ Fint LBUSER1;
+#endif
+#ifdef PP_STORE_LBUSER2
+ Fint LBUSER2;
+#endif
+#ifdef PP_STORE_LBUSER3
+ Fint LBUSER3;
+#endif
+#ifdef PP_STORE_LBUSER4
+ Fint LBUSER4;
+#endif
+#ifdef PP_STORE_LBUSER5
+ Fint LBUSER5;
+#endif
+#ifdef PP_STORE_LBUSER6
+ Fint LBUSER6;
+#endif
+#ifdef PP_STORE_LBUSER7
+ Fint LBUSER7;
+#endif
+#ifdef PP_STORE_BULEV
+ Freal BULEV;
+#endif
+#ifdef PP_STORE_BHULEV
+ Freal BHULEV;
+#endif
+#ifdef PP_STORE_BRSVD3
+ Freal BRSVD3;
+#endif
+#ifdef PP_STORE_BRSVD4
+ Freal BRSVD4;
+#endif
+#ifdef PP_STORE_BDATUM
+ Freal BDATUM;
+#endif
+#ifdef PP_STORE_BACC
+ Freal BACC;
+#endif
+#ifdef PP_STORE_BLEV
+ Freal BLEV;
+#endif
+#ifdef PP_STORE_BRLEV
+ Freal BRLEV;
+#endif
+#ifdef PP_STORE_BHLEV
+ Freal BHLEV;
+#endif
+#ifdef PP_STORE_BHRLEV
+ Freal BHRLEV;
+#endif
+#ifdef PP_STORE_BPLAT
+ Freal BPLAT;
+#endif
+#ifdef PP_STORE_BPLON
+ Freal BPLON;
+#endif
+#ifdef PP_STORE_BGOR
+ Freal BGOR;
+#endif
+#ifdef PP_STORE_BZY
+ Freal BZY;
+#endif
+#ifdef PP_STORE_BDY
+ Freal BDY;
+#endif
+#ifdef PP_STORE_BZX
+ Freal BZX;
+#endif
+#ifdef PP_STORE_BDX
+ Freal BDX;
+#endif
+#ifdef PP_STORE_BMDI
+ Freal BMDI;
+#endif
+#ifdef PP_STORE_BMKS
+ Freal BMKS;
+#endif
+};
+
+struct pp_rec {
+ int recno; /* record number */
+ PPhdr hdr; /* header structure */
+ long datapos; /* file pos data start (after any fortran record length int) in bytes */
+ long disklen; /* length on disks (words) -- including padding + before unpacking */
+ long datalen; /* data length (words) */
+
+ PPlevel *lev;
+ PPtime *time;
+ int zindex; /* index on z axis within a variable - used for detecting vars with irreg z,t */
+ int tindex; /* index on t axis within a variable - used for detecting vars with irreg z,t */
+ int disambig_index; /* index used for splitting variables with irreg z,t into
+ * sets of variables with regular z,t */
+ int supervar_index; /* when a variable is split, this is set to an index which is common
+ * across the set, but different from sets generated from other
+ * super-variables
+ */
+ Freal mean_period; /* period (in days) of time mean
+ (store here so as to calculate once only) */
+};
+
+
+/*---------------------------------------------------------*/
+
+/* Function like macros */
+/* The code profiler suggests that pp_compare_ints and pp_compare_reals are candidates for
+ * inlining; however, unfortunately this sometimes gets compiled with c89 which doesn't support
+ * inline functions. Use a #define for pp_compare_ints. pp_compare_reals, which is more
+ * awkward to #define, is just going to have to stay as it is for now (it's called less often).
+ */
+
+/* ----------------------------------------------------------- */
+
+/* Define some values which can be used for initialising variables
+ * to no particular value, but may aid debugging to not have them
+ * completely uninitialised. Should not be tested for in production
+ * code, as these could still happen to match a genuine value.
+ */
+
+#define UNSET_INT -999
+#define UNSET_REAL 1e9
+
+/* ----------------------------------------------------------- */
+
+#define pp_compare_ints(a,b) ((a)<(b)?(-1):(a)>(b)?1:0)
+
+/* ----------------------------------------------------------- */
+
+/* error-checking macros */
+
+/* these are to allow a compact way of incorporating error-checking of
+ * the return value of a function call, without obfuscating the basic purpose
+ * of the line of code, which is executing the function call.
+ *
+ * CKI used for integer functions which return negative value on failure
+ * CKP used for pointer functions which return NULL on failure
+ * CKF for floats for good measure (probably not used)
+ *
+ * put the ERRBLK (or ERRBLKI or ERRBLKP) at the end of the subroutine, with
+ * the "label" argument set to the subroutine name (as a string)
+ */
+
+#define FLT_ERR -1e38
+
+#ifdef DEBUG
+#define ERR abort();
+#else
+/* ERR: unconditional branch */
+#define ERR goto err;
+#endif
+
+#define CKI(i) if ((i) < 0){ ERR }
+#define CKP(p) if ((p) == NULL){ ERR }
+#define CKF(f) if ((f) == FLT_ERR){ ERR }
+
+/* ERRIF: conditional branch */
+#define ERRIF(i) if (i){ ERR }
+
+#define ERRBLK(label,rtn) err: pp_error(label); return (rtn);
+#define ERRBLKI(label) ERRBLK((label),-1);
+#define ERRBLKP(label) ERRBLK((label),NULL);
+#define ERRBLKF(label) ERRBLK((label),FLT_ERR);
+
+
+/* ----------------------------------------------------------- */
+
+/* prototypes */
+
+/* in cdunifpp_attribute.c: */
+CuAtt *pp_att_new(const char *, CuType, long, const void *, PPlist *);
+int pp_add_att(PPlist *, const char *, CuType, long, const void *, PPlist *);
+CuAtt *pp_string_att_new(const char *, const char *, PPlist *);
+int pp_add_string_att(PPlist *, const char *, const char *, PPlist *);
+int pp_add_string_att_if_set(PPlist *, const char *, const char *, PPlist *);
+int pp_copy_and_free_atts(CuFile *, CuVar *, PPlist *, PPlist *);
+
+/* in cdunifpp_axisvals.c: */
+PPdata *pp_data_new(CuType,int,PPlist *);
+PPdata *pp_regaxis_to_values(const PPregaxis *, PPlist *);
+PPdata *pp_zaxis_to_values(const PPzaxis *, PPlevvaltype, PPlist *);
+PPdata *pp_taxis_to_values(const PPtaxis *, PPlist *);
+PPdata *pp_taxis_to_boundary_values(const PPtaxis *, PPlist *);
+int pp_is_time_mean(Fint);
+int pp_grid_supported(const PPhdr *);
+int pp_axis_regular(const PPextravec, const PPrec *, const PPfile *);
+int pp_is_rotated_grid(const PPhdr *);
+Freal pp_mean_period(const PPtime *);
+Freal pp_time_diff(Fint, const PPdate *, const PPdate *);
+Freal pp_sec_to_day(long long);
+PPcalendartype pp_calendar_type(Fint);
+long long pp_gregorian_to_secs(const PPdate *);
+char *pp_t_units(const PPtaxis *, PPlist *);
+
+/* in cdunifpp_check.c: */
+int pp_check_sizes();
+
+
+/* in cdunifpp_compare.c: */
+/* int pp_compare_ints(Fint, Fint); */
+/* int pp_compare_reals(Freal, Freal); */
+/* int pp_compare_ptrs(const void *, const void *); */
+int pp_compare_records_between_vars(const PPrec *, const PPrec *);
+int pp_compare_mean_periods(const PPrec *, const PPrec *);
+int pp_both_values_in_range(Freal, Freal, Freal, Freal);
+int pp_compare_records_within_var(const PPrec *, const PPrec *);
+int pp_compare_records(const void *, const void *);
+int pp_records_from_different_vars(const PPrec *, const PPrec *);
+int pp_compare_regaxes(const void *, const void *);
+int pp_compare_rotmaps(const void *, const void *);
+int pp_compare_rotgrids(const void *, const void *);
+int pp_compare_xsaxes( const void *, const void *);
+int pp_compare_lists(const PPlist *, const PPlist *, int (*)(const void*, const void*));
+int pp_compare_levels(const void *, const void *);
+int pp_compare_zaxes(const void *, const void *);
+int pp_compare_times(const void *, const void *);
+int pp_compare_dates(const PPdate *, const PPdate *);
+int pp_compare_taxes(const void *, const void *);
+
+/* in cdunifpp_data.c: */
+int pp_data_copy(const CuFile *, const CuVar *, const long [], const long [], void *);
+int pp_data_read(const CuFile *, const CuVar *, const long [], const long [], void *);
+
+/* in cdunifpp_error.c: */
+int pp_switch_bug();
+int pp_error(const char*);
+int pp_errorhandle_init();
+int pp_error_mesg(const char *, const char *);
+
+/* in cdunifpp_filetype.c: */
+int pp_determine_file_type(PPfile *, const char *, int);
+int pp_determine_file_type_by_name(PPfile *, const char *);
+int pp_is_ppum_file(const char *, FILE *);
+int pp_determine_file_type_by_contents(PPfile *);
+int pp_valid_um_word2(Fint8);
+int pp_valid_pp_word1(Fint8,int);
+
+
+int pp_string_ends_with(const char *, const char *);
+
+/* in cdunifpp_linklist.c: */
+void *pp_list_new(PPlist *);
+int pp_list_free(PPlist *, int, PPlist *);
+int pp_list_size(const PPlist *);
+int pp_list_add(PPlist *, void *, PPlist *);
+int pp_list_del(PPlist *, void *, PPlist *);
+int pp_list_del_by_listel(PPlist *, PPlistel *, PPlist *);
+int pp_list_startwalk(const PPlist *, PPlisthandle *);
+void *pp_list_walk(PPlisthandle *,int);
+void *pp_list_find(PPlist *, const void *, int (*)(const void *, const void *), int, int *);
+
+typedef int(*free_func) (void *, PPlist *);
+
+int pp_list_add_or_find(PPlist *, void *,
+ int (*)(const void *, const void *), int,
+ free_func, int *, PPlist *);
+
+/* in cdunifpp_malloc.c: */
+void *pp_malloc(size_t, PPlist *);
+void *pp_dup(const void *, size_t, PPlist *);
+int pp_free(void *, PPlist *);
+int pp_free_all(PPlist *);
+
+/* in cdunifpp_ppcode.c: */
+char *pp_pplongname(int);
+char *pp_ppshortname(int);
+char *pp_ppunit(int);
+
+/* in cdunifpp_process.c: */
+int pp_process(CuFile *);
+int pp_test_skip_var(const PPhdr *, const PPlandmask *);
+int pp_initialise_records(PPrec**, int, PPlist *);
+int pp_set_disambig_index(PPgenaxis *, PPgenaxis *, PPrec **, int, int);
+int pp_var_has_regular_z_t(PPgenaxis *, PPgenaxis *, PPrec **, int);
+int pp_store_dim_names(PPdimnames *, const PPlist *, const CuDim *);
+int pp_get_cell_methods (const PPlist *, const PPhdr *, const CuDim *, char []);
+int pp_append_cell_method(char [], const char *, const char *);
+int pp_var_get_extra_atts(const CuVar *, const PPfieldvar *, const CuDim *, PPlist *, PPlist *);
+int pp_append_string(char *, const char *, int);
+PPlist *pp_get_global_attributes(const char *, const PPfile *, PPlist *);
+int pp_free_tmp_vars(PPlist *, PPlist *, PPlist *, PPlist *, PPlist *, PPlist *);
+
+/* in cdunifpp_read.c: */
+size_t pp_read_words(void *, size_t, PPconvert, const PPfile *);
+int pp_swapbytes(void *, int, int);
+void * pp_read_data_record(const PPrec *, const PPfile *, PPlist *);
+int pp_swap32couplets(char *,int);
+int pp_skip_fortran_record(const PPfile *);
+int pp_skip_word(const PPfile *);
+void *pp_read_header(const PPfile *, PPlist *);
+int pp_read_all_headers(CuFile *);
+int pp_store_header(PPhdr *, const void *);
+int pp_evaluate_lengths (const PPhdr *, const PPfile *, long *, long *);
+PPdata *pp_read_extradata(const PPrec *, const PPfile *, PPlist *, const PPextravec);
+int pp_extra_has_vector(const PPextravec,const PPrec *, const PPfile *);
+
+/* in cdunifpp_rotgrid.c */
+
+PProtmap *pp_get_rotmap(const PPhdr *, PPlist *, PPlist *);
+
+PProtgrid *pp_get_rotgrid(PPgenaxis *, PPgenaxis *, PPlist *, PPlist *);
+
+int pp_calc_rot_grid(PProtgrid *, PPdata **, PPdata **, PPlist *);
+
+/* in cdunifpp_stashname.c: */
+char *pp_stashname(int, int, int);
+
+/* in cdunifpp_stash2pp.c: */
+int pp_stashpp(int, int, int);
+
+/* in cdunifpp_struct.c: */
+CuFile *pp_create_file(const char *);
+int pp_delete_file(CuFile *);
+
+/* in cdunifpp_unwgdoswrap.c: */
+int pp_unwgdos_wrap(const void *, int, void *, long, Freal, PPlist *);
+
+/* in cdunifpp_varinfo.c: */
+int pp_var_lookup(const PPhdr *, PPstashmeta *) ;
+int pp_get_var_default_shortname(const PPhdr *, char *, int);
+int pp_get_var_default_longname(const PPhdr *, char *, int);
+int pp_get_var_default_units(const PPhdr *, char *, int);
+int pp_get_var_stash_model(const PPhdr *);
+int pp_get_var_stash_section(const PPhdr *);
+int pp_get_var_stash_item(const PPhdr *);
+int pp_get_var_packing(const PPhdr *);
+int pp_get_var_compression(const PPhdr *);
+int pp_get_var_processing(const PPhdr *);
+int pp_get_var_gridcode(const PPhdr *);
+int pp_get_var_name(int varid, const char *, CuVar *) ;
+void *pp_get_var_fill_value(const PPhdr *);
+int pp_var_is_land_mask(const PPhdr *);
+CuType pp_get_var_type(const PPhdr *);
+int pp_var_is_time_mean(const PPhdr *);
+int pp_var_is_time_min(const PPhdr *);
+int pp_var_is_time_max(const PPhdr *);
+int pp_var_is_time_variance(const PPhdr *);
+int pp_var_is_zonal_mean(const PPhdr *);
+int pp_var_is_vertical_mean(const PPhdr *);
+int pp_var_is_missing(const PPhdr *hdr);
+
+/* in cdunifpp_debug.c: */
+void pp_dump_header(const PPhdr *);
+void pp_dump_date(PPdate *);
+void pp_dump_time(PPtime *);
+void pp_dump_list(PPlist *, void (*)(void *));
+void pp_dump_taxis(PPgenaxis *);
+
+
+
+/* in cdunifpp_genaxis.c: */
+/* JAK 2005-01-10 */
+
+PPgenaxis *pp_genaxis_new(const PPaxisgentype, const PPdir, PPlist *);
+int pp_genaxis_free(PPgenaxis *, PPlist *);
+int pp_genaxis_compare(const void *, const void *);
+PPdata *pp_genaxis_to_values(const PPgenaxis *, int, PPlist *);
+PProtmap *pp_genaxis_rotmap(const PPgenaxis *);
+Fint pp_genaxis_len(const PPgenaxis *);
+PPdata *pp_genaxis_getCF(const PPgenaxis *, char *, char *, PPlist *, PPlist *);
+
+PPdata *pp_xsaxis_to_values(const PPxsaxis *, PPlist *);
+int pp_xsaxis_set(PPgenaxis *, const PPrec *, const PPfile *, const PPextravec, PPlist *);
+int pp_axistype(const PPxsaxis *);
+
+PPlevtype pp_zaxis_lev_type(const PPgenaxis *);
+PPlevtype pp_level_type(const PPhdr *);
+int pp_zaxis_set(PPgenaxis *, const PPhdr *);
+int pp_zaxis_add(PPgenaxis *, const PPlevel *, int *, PPlist *);
+
+int pp_taxis_set(PPgenaxis *, const PPhdr *);
+int pp_taxis_add(PPgenaxis *, const PPtime *, int *,PPlist *);
+int pp_taxis_is_time_mean(PPgenaxis *);
+
+int pp_regaxis_set(PPgenaxis *, PPaxisregtype, const PPhdr *, PPlist *, PPlist *);
+int pp_set_horizontal_axes(PPrec *, PPfile *,
+ PPgenaxis **, PPgenaxis **,
+ PPlist *, PPlist *);
+
+PPgenaxis *pp_get_taxis_from_list(const PPlist *);
+PPgenaxis *pp_get_zaxis_from_list(const PPlist *);
+PPgenaxis *pp_get_yaxis_from_list(const PPlist *);
+PPgenaxis *pp_get_xaxis_from_list(const PPlist *);
+
+int pp_genaxis_print(const PPgenaxis *, const char *);
+int pp_lev_set(PPlevel *, PPhdr *);
+int pp_time_set(PPtime *, PPhdr *);
+
+#define D(x) {printf("debug: %d\n",x);}
+
+#ifdef DEBUG
+#define DMESS(expr) printf("DBG: " #expr "\n")
+#else
+#define DMESS(expr)
+#endif
diff --git a/include/cdTime/cdunifpp/cdunifpp_frename.h b/include/cdTime/cdunifpp/cdunifpp_frename.h
new file mode 100644
index 0000000..ffc0344
--- /dev/null
+++ b/include/cdTime/cdunifpp/cdunifpp_frename.h
@@ -0,0 +1,68 @@
+/*
+ *
+ * Copyright (C) 2004 NERC DataGrid
+ * This software may be distributed under the terms of the
+ * CCLRC Licence for CCLRC Software
+ * <CDATDIR>/External_License/CCLRC_CDAT_License.txt
+ *
+ */
+/* including this header file will rename all the functions in the library
+ * used for WGDOS unpacking within cdunifpp, in order to avoid potential
+ * namespace conflicts
+ */
+
+#define bit_test pp_unwgdos__bit_test
+#define extrin pp_unwgdos__extrin
+#define move_bits pp_unwgdos__move_bits
+#define read_wgdos_header pp_unwgdos__read_wgdos_header
+#define unwgdos pp_unwgdos__unwgdos
+#define xpnd pp_unwgdos__xpnd
+#define c8_to_i4 pp_unwgdos__c8_to_i4
+#define c8toi4_ pp_unwgdos__c8toi4_
+#define c8_to_i8 pp_unwgdos__c8_to_i8
+#define c8toi8_ pp_unwgdos__c8toi8_
+#define c8_to_l4 pp_unwgdos__c8_to_l4
+#define c8tol4_ pp_unwgdos__c8tol4_
+#define c8_to_l8 pp_unwgdos__c8_to_l8
+#define c8tol8_ pp_unwgdos__c8tol8_
+#define c8_to_r4 pp_unwgdos__c8_to_r4
+#define c8tor4_ pp_unwgdos__c8tor4_
+#define c8_to_r8 pp_unwgdos__c8_to_r8
+#define c8tor8_ pp_unwgdos__c8tor8_
+#define cos_backspace pp_unwgdos__cos_backspace
+#define cosbackspace_ pp_unwgdos__cosbackspace_
+#define cos_close pp_unwgdos__cos_close
+#define cosclose_ pp_unwgdos__cosclose_
+#define cos_open pp_unwgdos__cos_open
+#define cosopen_ pp_unwgdos__cosopen_
+#define cos_read pp_unwgdos__cos_read
+#define cosread_ pp_unwgdos__cosread_
+#define cos_rewind pp_unwgdos__cos_rewind
+#define cosrewind_ pp_unwgdos__cosrewind_
+#define expand21_ pp_unwgdos__expand21_
+#define expand21_r4_ pp_unwgdos__expand21_r4_
+#define expand21_r8_ pp_unwgdos__expand21_r8_
+#define i4_to_i8 pp_unwgdos__i4_to_i8
+#define i8_to_i4 pp_unwgdos__i8_to_i4
+#define ibmi2_to_i4 pp_unwgdos__ibmi2_to_i4
+#define ibmi2toi4_ pp_unwgdos__ibmi2toi4_
+#define ibmi2_to_i8 pp_unwgdos__ibmi2_to_i8
+#define ibmi2toi8_ pp_unwgdos__ibmi2toi8_
+#define ibmi4_to_i4 pp_unwgdos__ibmi4_to_i4
+#define ibmi4toi4_ pp_unwgdos__ibmi4toi4_
+#define ibmi4_to_i8 pp_unwgdos__ibmi4_to_i8
+#define ibmi4toi8_ pp_unwgdos__ibmi4toi8_
+#define ibmr4_to_r4 pp_unwgdos__ibmr4_to_r4
+#define ibmr4tor4_ pp_unwgdos__ibmr4tor4_
+#define ibmr4_to_r8 pp_unwgdos__ibmr4_to_r8
+#define ibmr4tor8_ pp_unwgdos__ibmr4tor8_
+#define ibmr8_to_r8 pp_unwgdos__ibmr8_to_r8
+#define ibmr8tor8_ pp_unwgdos__ibmr8tor8_
+#define ii4toi8_ pp_unwgdos__ii4toi8_
+#define ii8toi4_ pp_unwgdos__ii8toi4_
+#define r4_to_r8 pp_unwgdos__r4_to_r8
+#define r4tor8_ pp_unwgdos__r4tor8_
+#define r8_to_r4 pp_unwgdos__r8_to_r4
+#define r8tor4_ pp_unwgdos__r8tor4_
+#define swap_bytes pp_unwgdos__swap_bytes
+#define swapbytes_ pp_unwgdos__swapbytes_
diff --git a/include/cdTime/cdunifpp/crayio.h b/include/cdTime/cdunifpp/crayio.h
new file mode 100644
index 0000000..7280a91
--- /dev/null
+++ b/include/cdTime/cdunifpp/crayio.h
@@ -0,0 +1,396 @@
+#if !defined(COS_HDR)
+#define COS_HDR
+
+#ifdef _CRAY
+#include <fortran.h>
+typedef _fcd fpchar;
+#else
+typedef char *fpchar;
+#endif
+
+#if defined _CRAY
+#if defined _CRAYMPP
+#define SHORT32
+#define INT64
+#define FLOAT32
+#else
+#define SHORT64
+#define INT64
+#define FLOAT64
+#endif
+#else
+#define SHORT16
+#define INT32
+#define FLOAT32
+#endif
+
+#define DOUBLE64
+#if defined _CRAY || defined __alpha || defined __ia64 || defined __x86_64__ || _MIPS_SZLONG == 64 || defined __64BIT__
+#define LONG64
+#else
+#define LONG32
+#define LONGLONG64
+#endif
+
+#ifdef _IBM
+
+#ifdef SHORT16
+typedef unsigned short int uint16;
+#endif
+#ifdef INT32
+typedef unsigned int uint32;
+#endif
+#ifdef SHORT32
+typedef unsigned short int uint32;
+#endif
+#ifdef FLOAT32
+typedef float float32;
+#endif
+#ifdef DOUBLE64
+typedef double float64;
+#endif
+#ifdef LONG64
+typedef unsigned long int uint64;
+#else
+typedef unsigned long long int uint64;
+#endif
+
+#else
+
+#ifdef SHORT16
+typedef short int int16;
+typedef unsigned short int uint16;
+#endif
+#ifdef INT32
+typedef int int32;
+typedef unsigned int uint32;
+#endif
+#ifdef SHORT32
+typedef short int int32;
+typedef unsigned short int uint32;
+#endif
+#ifdef FLOAT32
+typedef float float32;
+#endif
+#ifdef DOUBLE64
+typedef double float64;
+#endif
+#ifdef LONG64
+typedef long int int64;
+typedef unsigned long int uint64;
+#else
+typedef long long int int64;
+typedef unsigned long long int uint64;
+#endif
+
+#endif
+
+#define _IEEE4 0
+#define _IEEE8 1
+#define _CRAY8 2
+
+#ifndef _FLT_TYPE
+#ifdef _CRAY
+#ifndef _CRAYIEEE
+#define _FLT_TYPE _CRAY8
+#else
+#define _FLT_TYPE _IEEE8
+#endif
+#else
+#define _FLT_TYPE _IEEE4
+#endif
+#endif
+
+#ifndef _INT_TYPE
+#ifdef _CRAY
+#ifndef _CRAYIEEE
+#define _INT_TYPE _CRAY8
+#else
+#define _INT_TYPE _IEEE8
+#endif
+#else
+#define _INT_TYPE _IEEE4
+#endif
+#endif
+
+#if _FLT_TYPE == _CRAY8 || _FLT_TYPE == _IEEE8
+#define _FLT_SIZE 8
+#else
+#define _FLT_SIZE 4
+#endif
+
+#if _INT_TYPE == _CRAY8 || _INT_TYPE == _IEEE8
+#define _INT_SIZE 8
+#else
+#define _INT_SIZE 4
+#endif
+
+#if _FLT_SIZE == 8
+#ifdef FLOAT32
+#define REAL double
+#else
+#define REAL float
+#endif
+#else
+#define REAL float
+#endif
+
+#if _INT_SIZE == 8
+#ifdef INT32
+#ifdef LONG64
+#define INTEGER long
+#else
+#define INTEGER long long
+#endif
+#else
+#define INTEGER int
+#endif
+#else
+#define INTEGER int
+#endif
+
+#if defined __alpha || defined __ia64 || defined __x86_64__ || defined __i386
+#define LITTLE__ENDIAN
+#else
+#define BIG__ENDIAN
+#endif
+
+#ifdef _CRAY
+#ifndef _CRAYIEEE
+#define _CRAYNONIEEE
+#endif
+#endif
+
+#ifdef _CRAY
+#ifndef _CRAYMPP
+#define _CRAYPVP
+#endif
+#endif
+
+#define CBCW 0 /* COS block control word */
+#define CEOR 010 /* COS end of record */
+#define CEOF 016 /* COS end of file */
+#define CEOD 017 /* COS end of data */
+
+#define CRAYWORD 8 /* Size of Cray word in bytes */
+#define BLOCKSIZE 4096 /* Size of Cray block in bytes */
+
+#define MINSEXP32 0x3f6b /* min valid (translatable subnormal)
+ Cray masked exponent for IEEE 32 bit f.p. */
+#define MINEXP32 0x3f83 /* min valid (translatable normal)
+ Cray masked exponent for IEEE 32 bit f.p. */
+#define MAXEXP32 0x4080 /* max valid (translatable)
+ Cray masked exponent for IEEE 32 bit f.p. */
+#define MINSEXP64 0x3bce /* min valid (translatable subnormal)
+ Cray masked exponent for IEEE 64 bit f.p. */
+#define MINEXP64 0x3c03 /* min valid (translatable normal)
+ Cray masked exponent for IEEE 64 bit f.p. */
+#define MAXEXP64 0x4400 /* max valid (translatable)
+ Cray masked exponent for IEEE 64 bit f.p. */
+
+#define MINCEXP 0x2003 /* min valid Cray masked exponent */
+#define MAXCEXP 0x5ffe /* max valid Cray masked exponent */
+
+#define MINI32EXP 1 /* min valid 32 bit IEEE masked exponent */
+#define MAXI32EXP 254 /* max valid 32 bit IEEE masked exponent */
+#define MINI64EXP 1 /* min valid 64 bit IEEE masked exponent */
+#define MAXI64EXP 2046 /* max valid 64 bit IEEE masked exponent */
+
+#define CBIAS 040000 /* Cray f.p. exponent bias */
+#define I32BIAS 0177 /* IEEE 32 bit f.p. exponent bias */
+#define I64BIAS 01777 /* IEEE 64 bit f.p. exponent bias */
+
+#define CSIGNMASK 0x80 /* Mask to get 1st of 8 bits */
+#define CSIGNMASK1 0x80000000 /* Mask to get 1st of 32 bits */
+#define I32_NAN 0x7fffffff
+#define I32_INFP 0x7f800000
+#define I32_INFN 0xff800000
+#define I32_ZEROP 0x00000000
+#define I32_ZERON 0x80000000
+#ifdef LONG64
+#define CSIGNMASK2 0x8000000000000000l /* Mask to get 1st of 64 bits */
+#define I64_NAN 0x7fffffffffffffffl
+#define I64_INFP 0x7ff0000000000000l
+#define I64_INFN 0xfff0000000000000l
+#else
+#define CSIGNMASK2 0x8000000000000000ll /* Mask to get 1st of 64 bits */
+#define I64_NAN 0x7fffffffffffffffll
+#define I64_INFP 0x7ff0000000000000ll
+#define I64_INFN 0xfff0000000000000ll
+#endif
+
+#if defined _CRAY
+#define cosopen COSOPEN
+#define cosclose COSCLOSE
+#define cosrewind COSREWIND
+#define cosbackspace COSBACKSPACE
+#define cosread COSREAD
+#define swapbytes SWAPBYTES
+#define c8tor4 C8TOR4
+#define c8toi4 C8TOI4
+#define c8tol4 C8TOL4
+#define c8tor8 C8TOR8
+#define c8toi8 C8TOI8
+#define c8tol8 C8TOL8
+#define r8tor4 R8TOR4
+#define ii8toi4 II8TOI4
+#define r4tor8 R4TOR8
+#define ii4toi8 II4TOI8
+#define r4toc8 R4TOC8
+#define i4toc8 I4TOC8
+#define l4toc8 L4TOC8
+#define r8toc8 R8TOC8
+#define i8toc8 I8TOC8
+#define l8toc8 L8TOC8
+#define ibmi4toi4 IBMI4TOI4
+#define ibmi2toi4 IBMI2TOI4
+#define ibmr4tor4 IBMR4TOR4
+#define ibmi4toi8 IBMI4TOI8
+#define ibmi2toi8 IBMI2TOI8
+#define ibmr4tor8 IBMR4TOR8
+#define ibmr8tor8 IBMR8TOR8
+#ifdef _CRAYPVP
+#define ibmi4toc8 IBMI4TOC8
+#define ibmi2toc8 IBMI2TOC8
+#define ibmr4toc8 IBMR4TOC8
+#define ibmr8toc8 IBMR8TOC8
+#endif
+#define expand21 EXPAND21
+#ifndef _CRAYPVP
+#define expand21_r4 EXPAND21_R4_
+#define expand21_r8 EXPAND21_R8_
+#endif
+#elif defined __sun || defined __sgi || defined __osf__ || defined __uxpv__ || defined __linux || defined _SX
+#define cosopen cosopen_
+#define cosclose cosclose_
+#define cosrewind cosrewind_
+#define cosbackspace cosbackspace_
+#define cosread cosread_
+#define swapbytes swapbytes_
+#define c8tor4 c8tor4_
+#define c8toi4 c8toi4_
+#define c8tol4 c8tol4_
+#define c8tor8 c8tor8_
+#define c8toi8 c8toi8_
+#define c8tol8 c8tol8_
+#define r8tor4 r8tor4_
+#define ii8toi4 ii8toi4_
+#define r4tor8 r4tor8_
+#define ii4toi8 ii4toi8_
+#define ibmi4toi4 ibmi4toi4_
+#define ibmi2toi4 ibmi2toi4_
+#define ibmr4tor4 ibmr4tor4_
+#define ibmi4toi8 ibmi4toi8_
+#define ibmi2toi8 ibmi2toi8_
+#define ibmr4tor8 ibmr4tor8_
+#define ibmr8tor8 ibmr8tor8_
+#define expand21 expand21_
+#define expand21_r4 expand21_r4_
+#define expand21_r8 expand21_r8_
+#endif
+
+/* definition of a cosfile */
+
+typedef struct {
+ char *fname; /* file name */
+ FILE *fp; /* current file */
+ unsigned long fwi; /* forward index of current bcw/rcw */
+ unsigned long pri; /* backward index of current bcw/rcw */
+} COSFILE;
+
+/* Routines callable from C */
+
+COSFILE *cos_open (char *, char *);
+int cos_close (COSFILE *);
+int cos_rewind (COSFILE *);
+int cos_backspace (COSFILE *);
+int cos_read (COSFILE *, void *, int, int *);
+void swap_bytes(void *, int, int);
+int c8_to_r4(void *, void *, int);
+int c8_to_i4(void *, void *, int);
+int c8_to_l4(void *, void *, int);
+int c8_to_r8(void *, void *, int);
+int c8_to_i8(void *, void *, int);
+int c8_to_l8(void *, void *, int);
+int r8_to_r4(void *, void *, int);
+int i8_to_i4(void *, void *, int);
+int r4_to_r8(void *, void *, int);
+int i4_to_i8(void *, void *, int);
+#ifdef _CRAY
+int r4_to_c8(void *, void *, int);
+int i4_to_c8(void *, void *, int);
+int l4_to_c8(void *, void *, int);
+int r8_to_c8(void *, void *, int);
+int i8_to_c8(void *, void *, int);
+int l8_to_c8(void *, void *, int);
+#endif
+int ibmi4_to_i4(void *, void *, int);
+int ibmi2_to_i4(void *, void *, int, int);
+int ibmr4_to_r4(void *, void *, int);
+int ibmi4_to_i8(void *, void *, int, int);
+int ibmi2_to_i8(void *, void *, int, int);
+int ibmr4_to_r8(void *, void *, int, int);
+int ibmr8_to_r8(void *, void *, int);
+#ifdef _CRAYPVP
+int ibmi4_to_c8(void *, void *, int, int);
+int ibmi2_to_c8(void *, void *, int, int);
+int ibmr4_to_c8(void *, void *, int, int);
+int ibmr8_to_c8(void *, void *, int);
+#endif
+
+/* Routines callable from Fortran */
+
+void cosopen (COSFILE **, fpchar, fpchar, INTEGER *, long, long);
+void cosclose (COSFILE **, INTEGER *);
+void cosrewind (COSFILE **, INTEGER *);
+void cosbackspace (COSFILE **, INTEGER *);
+void cosread (COSFILE **, void *, INTEGER *, INTEGER *, INTEGER *);
+void swapbytes(void *, INTEGER *, INTEGER *);
+void c8tor4(void *, void *, INTEGER *, INTEGER *);
+void c8toi4(void *, void *, INTEGER *, INTEGER *);
+void c8tol4(void *, void *, INTEGER *, INTEGER *);
+void c8tor8(void *, void *, INTEGER *, INTEGER *);
+void c8toi8(void *, void *, INTEGER *, INTEGER *);
+void c8tol8(void *, void *, INTEGER *, INTEGER *);
+void expand21(INTEGER *, void *, void *, INTEGER *);
+#ifndef _CRAYPVP
+void expand21_r4(INTEGER *, void *, void *, INTEGER *);
+void expand21_r8(INTEGER *, void *, void *, INTEGER *);
+#endif
+void r8tor4(void *, void *, INTEGER *, INTEGER *);
+void ii8toi4(void *, void *, INTEGER *, INTEGER *);
+void r4tor8(void *, void *, INTEGER *, INTEGER *);
+void ii4toi8(void *, void *, INTEGER *, INTEGER *);
+#ifdef _CRAY
+void r4toc8(void *, void *, INTEGER *, INTEGER *);
+void i4toc8(void *, void *, INTEGER *, INTEGER *);
+void l4toc8(void *, void *, INTEGER *, INTEGER *);
+void r8toc8(void *, void *, INTEGER *, INTEGER *);
+void i8toc8(void *, void *, INTEGER *, INTEGER *);
+void l8toc8(void *, void *, INTEGER *, INTEGER *);
+#endif
+void ibmi4toi4 (void *, void *, INTEGER *, INTEGER *);
+void ibmi2toi4 (void *, void *, INTEGER *, INTEGER *, INTEGER *);
+void ibmr4tor4 (void *, void *, INTEGER *, INTEGER *);
+void ibmi4toi8 (void *, void *, INTEGER *, INTEGER *, INTEGER *);
+void ibmi2toi8 (void *, void *, INTEGER *, INTEGER *, INTEGER *);
+void ibmr4tor8 (void *, void *, INTEGER *, INTEGER *, INTEGER *);
+void ibmr8tor8 (void *, void *, INTEGER *, INTEGER *);
+#ifdef _CRAYPVP
+void ibmi4toc8 (void *, void *, INTEGER *, INTEGER *, INTEGER *);
+void ibmi2toc8 (void *, void *, INTEGER *, INTEGER *, INTEGER *);
+void ibmr4toc8 (void *, void *, INTEGER *, INTEGER *, INTEGER *);
+void ibmr8toc8 (void *, void *, INTEGER *, INTEGER *);
+#endif
+#ifdef _CRAY
+int CRY2CRI(int *, int *, void *, int *, void *, int *, int *, int *);
+int CRI2CRY(int *, int *, void *, int *, void *, int *, int *, int *);
+int IEG2CRI(int *, int *, void *, int *, void *, int *, int *, int *);
+int CRI2IEG(int *, int *, void *, int *, void *, int *, int *, int *);
+int IBM2CRI(int *, int *, void *, int *, void *, int *, int *, int *);
+#endif
+#ifdef _CRAYPVP
+int IBM2CRAY(int *, int *, void *, int *, void *);
+#endif
+
+#endif
diff --git a/include/cdTime/cdunifpp/util.h b/include/cdTime/cdunifpp/util.h
new file mode 100644
index 0000000..8876188
--- /dev/null
+++ b/include/cdTime/cdunifpp/util.h
@@ -0,0 +1,251 @@
+#if !defined(UTIL_HDR)
+#define UTIL_HDR
+
+#include <stdio.h>
+
+#if defined _CRAY
+#if defined _CRAYMPP
+#define SHORT32
+#define INT64
+#define FLOAT32
+#else
+#define SHORT64
+#define INT64
+#define FLOAT64
+#endif
+#else
+#define SHORT16
+#define INT32
+#define FLOAT32
+#endif
+
+#define DOUBLE64
+#if defined _CRAY || defined __alpha || defined __ia64 || defined __x86_64__ || _MIPS_SZLONG == 64 || defined __64BIT__
+#define LONG64
+#else
+#define LONG32
+#define LONGLONG64
+#endif
+
+#ifdef _IBM
+
+#ifdef SHORT16
+typedef unsigned short int uint16;
+#endif
+#ifdef INT32
+typedef unsigned int uint32;
+#endif
+#ifdef SHORT32
+typedef unsigned short int uint32;
+#endif
+#ifdef FLOAT32
+typedef float float32;
+#endif
+#ifdef DOUBLE64
+typedef double float64;
+#endif
+#ifdef LONG64
+typedef unsigned long int uint64;
+#else
+typedef unsigned long long int uint64;
+#endif
+
+#else
+
+#ifdef SHORT16
+typedef short int int16;
+typedef unsigned short int uint16;
+#endif
+#ifdef INT32
+typedef int int32;
+typedef unsigned int uint32;
+#endif
+#ifdef SHORT32
+typedef short int int32;
+typedef unsigned short int uint32;
+#endif
+#ifdef FLOAT32
+typedef float float32;
+#endif
+#ifdef DOUBLE64
+typedef double float64;
+#endif
+#ifdef LONG64
+typedef long int int64;
+typedef unsigned long int uint64;
+#else
+typedef long long int int64;
+typedef unsigned long long int uint64;
+#endif
+
+#endif
+
+#define _IEEE4 0
+#define _IEEE8 1
+#define _CRAY8 2
+
+#ifndef _FLT_TYPE
+#ifdef _CRAY
+#ifndef _CRAYIEEE
+#define _FLT_TYPE _CRAY8
+#else
+#define _FLT_TYPE _IEEE8
+#endif
+#else
+#define _FLT_TYPE _IEEE4
+#endif
+#endif
+
+#ifndef _INT_TYPE
+#ifdef _CRAY
+#ifndef _CRAYIEEE
+#define _INT_TYPE _CRAY8
+#else
+#define _INT_TYPE _IEEE8
+#endif
+#else
+#define _INT_TYPE _IEEE4
+#endif
+#endif
+
+#if _FLT_TYPE == _CRAY8 || _FLT_TYPE == _IEEE8
+#define _FLT_SIZE 8
+#else
+#define _FLT_SIZE 4
+#endif
+
+#if _INT_TYPE == _CRAY8 || _INT_TYPE == _IEEE8
+#define _INT_SIZE 8
+#else
+#define _INT_SIZE 4
+#endif
+
+#if _FLT_SIZE == 8
+#ifdef FLOAT32
+#define REAL double
+#else
+#define REAL float
+#endif
+#else
+#define REAL float
+#endif
+
+#if _INT_SIZE == 8
+#ifdef INT32
+#ifdef LONG64
+#define INTEGER long
+#else
+#define INTEGER long long
+#endif
+#else
+#define INTEGER int
+#endif
+#else
+#define INTEGER int
+#endif
+
+#if defined __alpha || defined __ia64 || defined __x86_64__ || defined __i386
+#define LITTLE__ENDIAN
+#else
+#define BIG__ENDIAN
+#endif
+
+#ifdef _CRAY
+#ifndef _CRAYIEEE
+#define _CRAYNONIEEE
+#endif
+#endif
+
+#ifdef _CRAY
+#ifndef _CRAYMPP
+#define _CRAYPVP
+#endif
+#endif
+
+#if defined _CRAY
+#define swapbytes SWAPBYTES
+#define expand21 EXPAND21
+#ifndef _CRAYPVP
+#define expand21_r4 EXPAND21_R4_
+#define expand21_r8 EXPAND21_R8_
+#endif
+#elif defined __sun || defined __sgi || defined __osf__ || defined __uxpv__ || defined __linux || defined _SX
+#define swapbytes swapbytes_
+#define expand21 expand21_
+#define expand21_r4 expand21_r4_
+#define expand21_r8 expand21_r8_
+#endif
+
+/* definition of a cosfile */
+
+typedef struct {
+ char *fname; /* file name */
+ FILE *fp; /* current file */
+ unsigned long fwi; /* forward index of current bcw/rcw */
+ unsigned long pri; /* backward index of current bcw/rcw */
+} COSFILE;
+
+/* Routines callable from C */
+
+COSFILE *cos_open (char *, char *);
+int cos_close (COSFILE *);
+int cos_rewind (COSFILE *);
+int cos_backspace (COSFILE *);
+int cos_read (COSFILE *, void *, int, int *);
+int c8_to_r4(void *, void *, int);
+int c8_to_i4(void *, void *, int);
+int c8_to_l4(void *, void *, int);
+int c8_to_r8(void *, void *, int);
+int c8_to_i8(void *, void *, int);
+int c8_to_l8(void *, void *, int);
+int r8_to_r4(void *, void *, int);
+int i8_to_i4(void *, void *, int);
+int r4_to_r8(void *, void *, int);
+int i4_to_i8(void *, void *, int);
+#ifdef _CRAY
+int r4_to_c8(void *, void *, int);
+int i4_to_c8(void *, void *, int);
+int l4_to_c8(void *, void *, int);
+int r8_to_c8(void *, void *, int);
+int i8_to_c8(void *, void *, int);
+int l8_to_c8(void *, void *, int);
+#endif
+int ibmi4_to_i4(void *, void *, int);
+int ibmi2_to_i4(void *, void *, int, int);
+int ibmr4_to_r4(void *, void *, int);
+int ibmi4_to_i8(void *, void *, int, int);
+int ibmi2_to_i8(void *, void *, int, int);
+int ibmr4_to_r8(void *, void *, int, int);
+int ibmr8_to_r8(void *, void *, int);
+#ifdef _CRAYPVP
+int ibmi4_to_c8(void *, void *, int, int);
+int ibmi2_to_c8(void *, void *, int, int);
+int ibmr4_to_c8(void *, void *, int, int);
+int ibmr8_to_c8(void *, void *, int);
+#endif
+void swap_bytes(void *, INTEGER, INTEGER);
+
+/* Routines callable from Fortran and C */
+
+void expand21(INTEGER *, void *, void *, INTEGER *);
+#ifndef _CRAYPVP
+void expand21_r4(INTEGER *, void *, void *, INTEGER *);
+void expand21_r8(INTEGER *, void *, void *, INTEGER *);
+#endif
+#ifdef _CRAY
+int CRY2CRI(int *, int *, void *, int *, void *, int *, int *, int *);
+int CRI2CRY(int *, int *, void *, int *, void *, int *, int *, int *);
+int IEG2CRI(int *, int *, void *, int *, void *, int *, int *, int *);
+int CRI2IEG(int *, int *, void *, int *, void *, int *, int *, int *);
+int IBM2CRI(int *, int *, void *, int *, void *, int *, int *, int *);
+#endif
+#ifdef _CRAYPVP
+int IBM2CRAY(int *, int *, void *, int *, void *);
+int CRAY2IBM(int *, int *, void *, int *, void *);
+#endif
+#ifdef _CRAYNONIEEE
+int CRAY2IEG(int *, int *, void *, int *, void *);
+int IEG2CRAY(int *, int *, void *, int *, void *);
+#endif
+
+#endif
diff --git a/include/cdTime/cdunifpp/vardef.h b/include/cdTime/cdunifpp/vardef.h
new file mode 100644
index 0000000..4058341
--- /dev/null
+++ b/include/cdTime/cdunifpp/vardef.h
@@ -0,0 +1,67 @@
+#include "util.h"
+
+#define _IEEE4 0
+#define _IEEE8 1
+#define _CRAY8 2
+
+#ifndef _FLT_TYPE
+#ifdef _CRAY
+#ifndef _CRAYIEEE
+#define _FLT_TYPE _CRAY8
+#else
+#define _FLT_TYPE _IEEE8
+#endif
+#else
+#define _FLT_TYPE _IEEE4
+#endif
+#endif
+
+#ifndef _INT_TYPE
+#ifdef _CRAY
+#ifndef _CRAYIEEE
+#define _INT_TYPE _CRAY8
+#else
+#define _INT_TYPE _IEEE8
+#endif
+#else
+#define _INT_TYPE _IEEE4
+#endif
+#endif
+
+#if _FLT_TYPE == _CRAY8 || _FLT_TYPE == _IEEE8
+#define _FLT_SIZE 8
+#else
+#define _FLT_SIZE 4
+#endif
+
+#if _INT_TYPE == _CRAY8 || _INT_TYPE == _IEEE8
+#define _INT_SIZE 8
+#else
+#define _INT_SIZE 4
+#endif
+
+#if _FLT_SIZE == 8
+#define real8
+#ifdef FLOAT32
+#define REAL double
+#else
+#define REAL float
+#endif
+#else
+#define REAL float
+#endif
+
+#if _INT_SIZE == 8
+#define int8
+#ifdef INT32
+#ifdef LONG64
+#define INTEGER long
+#else
+#define INTEGER long long
+#endif
+#else
+#define INTEGER int
+#endif
+#else
+#define INTEGER int
+#endif
diff --git a/include/cdTime/cfortran.h b/include/cdTime/cfortran.h
new file mode 100644
index 0000000..8ecd155
--- /dev/null
+++ b/include/cdTime/cfortran.h
@@ -0,0 +1,2369 @@
+/* cfortran.h 4.3 */
+/* www-zeus.desy.de/~burow OR anonymous ftp at zebra.desy.de */
+/* Burkhard Burow burow at desy.de 1990 - 1998. */
+
+#ifndef __CFORTRAN_LOADED
+#define __CFORTRAN_LOADED
+
+/*
+ THIS FILE IS PROPERTY OF BURKHARD BUROW. IF YOU ARE USING THIS FILE YOU
+ SHOULD ALSO HAVE ACCESS TO CFORTRAN.DOC WHICH PROVIDES TERMS FOR USING,
+ MODIFYING, COPYING AND DISTRIBUTING THE CFORTRAN.H PACKAGE.
+*/
+
+/*
+ Avoid symbols already used by compilers and system *.h:
+ __ - OSF1 zukal06 V3.0 347 alpha, cc -c -std1 cfortest.c
+
+ */
+
+
+/* First prepare for the C compiler. */
+
+#ifndef ANSI_C_preprocessor /* i.e. user can override. */
+#ifdef __CF__KnR
+#define ANSI_C_preprocessor 0
+#else
+#ifdef __STDC__
+#define ANSI_C_preprocessor 1
+#else
+#define _cfleft 1
+#define _cfright
+#define _cfleft_cfright 0
+#define ANSI_C_preprocessor _cfleft/**/_cfright
+#endif
+#endif
+#endif
+
+#if ANSI_C_preprocessor
+#define _0(A,B) A##B
+#define _(A,B) _0(A,B) /* see cat,xcat of K&R ANSI C p. 231 */
+#define _2(A,B) A##B /* K&R ANSI C p.230: .. identifier is not replaced */
+#define _3(A,B,C) _(A,_(B,C))
+#else /* if it turns up again during rescanning. */
+#define _(A,B) A/**/B
+#define _2(A,B) A/**/B
+#define _3(A,B,C) A/**/B/**/C
+#endif
+
+#if (defined(vax)&&defined(unix)) || (defined(__vax__)&&defined(__unix__))
+#define VAXUltrix
+#endif
+
+#include <stdio.h> /* NULL [in all machines stdio.h] */
+#include <string.h> /* strlen, memset, memcpy, memchr. */
+#if !( defined(VAXUltrix) || defined(sun) || (defined(apollo)&&!defined(__STDCPP__)) )
+#include <stdlib.h> /* malloc,free */
+#else
+#include <malloc.h> /* Had to be removed for DomainOS h105 10.4 sys5.3 425t*/
+#ifdef apollo
+#define __CF__APOLLO67 /* __STDCPP__ is in Apollo 6.8 (i.e. ANSI) and onwards */
+#endif
+#endif
+
+#if !defined(__GNUC__) && !defined(__sun) && (defined(sun)||defined(VAXUltrix)||defined(lynx))
+#define __CF__KnR /* Sun, LynxOS and VAX Ultrix cc only supports K&R. */
+ /* Manually define __CF__KnR for HP if desired/required.*/
+#endif /* i.e. We will generate Kernighan and Ritchie C. */
+/* Note that you may define __CF__KnR before #include cfortran.h, in order to
+generate K&R C instead of the default ANSI C. The differences are mainly in the
+function prototypes and declarations. All machines, except the Apollo, work
+with either style. The Apollo's argument promotion rules require ANSI or use of
+the obsolete std_$call which we have not implemented here. Hence on the Apollo,
+only C calling FORTRAN subroutines will work using K&R style.*/
+
+
+/* Remainder of cfortran.h depends on the Fortran compiler. */
+
+#if defined(CLIPPERFortran) || defined(pgiFortran)
+#define f2cFortran
+#endif
+
+/* VAX/VMS does not let us \-split long #if lines. */
+/* Split #if into 2 because some HP-UX can't handle long #if */
+#if !(defined(NAGf90Fortran)||defined(f2cFortran)||defined(hpuxFortran)||defined(apolloFortran)||defined(sunFortran)||defined(IBMR2Fortran)||defined(CRAYFortran))
+#if !(defined(mipsFortran)||defined(DECFortran)||defined(vmsFortran)||defined(CONVEXFortran)||defined(PowerStationFortran)||defined(AbsoftUNIXFortran)||defined(AbsoftProFortran)||defined(SXFortran))
+/* If no Fortran compiler is given, we choose one for the machines we know. */
+#if defined(lynx) || defined(VAXUltrix)
+#define f2cFortran /* Lynx: Only support f2c at the moment.
+ VAXUltrix: f77 behaves like f2c.
+ Support f2c or f77 with gcc, vcc with f2c.
+ f77 with vcc works, missing link magic for f77 I/O.*/
+#endif
+#if defined(__hpux) /* 921107: Use __hpux instead of __hp9000s300 */
+#define hpuxFortran /* Should also allow hp9000s7/800 use.*/
+#endif
+#if defined(apollo)
+#define apolloFortran /* __CF__APOLLO67 also defines some behavior. */
+#endif
+#if defined(sun) || defined(__sun)
+#define sunFortran
+#endif
+#if defined(_IBMR2)
+#define IBMR2Fortran
+#endif
+#if defined(_CRAY)
+#define CRAYFortran /* _CRAYT3E also defines some behavior. */
+#endif
+#if defined(_SX)
+#define SXFortran
+#endif
+#if defined(mips) || defined(__mips)
+#define mipsFortran
+#endif
+#if defined(vms) || defined(__vms)
+#define vmsFortran
+#endif
+#if defined(__alpha) && defined(__unix__)
+#define DECFortran
+#endif
+#if defined(__ia64) && defined(__unix__)
+#define LinuxFortran
+#endif
+#if defined(__x86_64__) && defined(__unix__)
+#define LinuxFortran
+#endif
+#if defined(__convex__)
+#define CONVEXFortran
+#endif
+#if defined(VISUAL_CPLUSPLUS)
+#define PowerStationFortran
+#endif
+#endif /* ...Fortran */
+#endif /* ...Fortran */
+
+/* Split #if into 2 because some HP-UX can't handle long #if */
+#if !(defined(NAGf90Fortran)||defined(f2cFortran)||defined(hpuxFortran)||defined(apolloFortran)||defined(sunFortran)||defined(IBMR2Fortran)||defined(CRAYFortran))
+#if !(defined(mipsFortran)||defined(DECFortran)||defined(vmsFortran)||defined(CONVEXFortran)||defined(PowerStationFortran)||defined(AbsoftUNIXFortran)||defined(AbsoftProFortran)||defined(SXFortran))
+/* If your compiler barfs on ' #error', replace # with the trigraph for # */
+ #error "cfortran.h: Can't find your environment among:\
+ - MIPS cc and f77 2.0. (e.g. Silicon Graphics, DECstations, ...) \
+ - IBM AIX XL C and FORTRAN Compiler/6000 Version 01.01.0000.0000 \
+ - VAX VMS CC 3.1 and FORTRAN 5.4. \
+ - Alpha VMS DEC C 1.3 and DEC FORTRAN 6.0. \
+ - Alpha OSF DEC C and DEC Fortran for OSF/1 AXP Version 1.2 \
+ - Apollo DomainOS 10.2 (sys5.3) with f77 10.7 and cc 6.7. \
+ - CRAY \
+ - NEC SX-4 SUPER-UX \
+ - CONVEX \
+ - Sun \
+ - PowerStation Fortran with Visual C++ \
+ - HP9000s300/s700/s800 Latest test with: HP-UX A.08.07 A 9000/730 \
+ - LynxOS: cc or gcc with f2c. \
+ - VAXUltrix: vcc,cc or gcc with f2c. gcc or cc with f77. \
+ - f77 with vcc works; but missing link magic for f77 I/O. \
+ - NO fort. None of gcc, cc or vcc generate required names.\
+ - f2c : Use #define f2cFortran, or cc -Df2cFortran \
+ - NAG f90: Use #define NAGf90Fortran, or cc -DNAGf90Fortran \
+ - Absoft UNIX F77: Use #define AbsoftUNIXFortran or cc -DAbsoftUNIXFortran \
+ - Absoft Pro Fortran: Use #define AbsoftProFortran \
+ - Portland Group Fortran: Use #define pgiFortran"
+/* Compiler must throw us out at this point! */
+#endif
+#endif
+
+
+#if defined(VAXC) && !defined(__VAXC)
+#define OLD_VAXC
+#pragma nostandard /* Prevent %CC-I-PARAMNOTUSED. */
+#endif
+
+/* Throughout cfortran.h we use: UN = Uppercase Name. LN = Lowercase Name. */
+
+#if defined(f2cFortran) || defined(NAGf90Fortran) || defined(DECFortran) || defined(mipsFortran) || defined(apolloFortran) || defined(sunFortran) || defined(CONVEXFortran) || defined(SXFortran) || defined(extname)
+#define CFC_(UN,LN) _(LN,_) /* Lowercase FORTRAN symbols. */
+#define orig_fcallsc(UN,LN) CFC_(UN,LN)
+#else
+#if defined(CRAYFortran) || defined(PowerStationFortran) || defined(AbsoftProFortran)
+#ifdef _CRAY /* (UN), not UN, circumvents CRAY preprocessor bug. */
+#define CFC_(UN,LN) (UN) /* Uppercase FORTRAN symbols. */
+#else /* At least VISUAL_CPLUSPLUS barfs on (UN), so need UN. */
+#define CFC_(UN,LN) UN /* Uppercase FORTRAN symbols. */
+#endif
+#define orig_fcallsc(UN,LN) CFC_(UN,LN) /* CRAY insists on arg.'s here. */
+#else /* For following machines one may wish to change the fcallsc default. */
+#define CF_SAME_NAMESPACE
+#ifdef vmsFortran
+#define CFC_(UN,LN) LN /* Either case FORTRAN symbols. */
+ /* BUT we usually use UN for C macro to FORTRAN routines, so use LN here,*/
+ /* because VAX/VMS doesn't do recursive macros. */
+#define orig_fcallsc(UN,LN) UN
+#else /* HP-UX without +ppu or IBMR2 without -qextname. NOT reccomended. */
+#define CFC_(UN,LN) LN /* Lowercase FORTRAN symbols. */
+#define orig_fcallsc(UN,LN) CFC_(UN,LN)
+#endif /* vmsFortran */
+#endif /* CRAYFortran PowerStationFortran */
+#endif /* ....Fortran */
+
+#define fcallsc(UN,LN) orig_fcallsc(UN,LN)
+#define preface_fcallsc(P,p,UN,LN) CFC_(_(P,UN),_(p,LN))
+#define append_fcallsc(P,p,UN,LN) CFC_(_(UN,P),_(LN,p))
+
+#define C_FUNCTION(UN,LN) fcallsc(UN,LN)
+#define FORTRAN_FUNCTION(UN,LN) CFC_(UN,LN)
+
+#ifndef COMMON_BLOCK
+#ifndef CONVEXFortran
+#ifndef CLIPPERFortran
+#if !(defined(AbsoftUNIXFortran)||defined(AbsoftProFortran))
+#define COMMON_BLOCK(UN,LN) CFC_(UN,LN)
+#else
+#define COMMON_BLOCK(UN,LN) _(_C,LN)
+#endif /* AbsoftUNIXFortran or AbsoftProFortran */
+#else
+#define COMMON_BLOCK(UN,LN) _(LN,__)
+#endif /* CLIPPERFortran */
+#else
+#define COMMON_BLOCK(UN,LN) _3(_,LN,_)
+#endif /* CONVEXFortran */
+#endif /* COMMON_BLOCK */
+
+#ifndef DOUBLE_PRECISION
+#if defined(CRAYFortran) && !defined(_CRAYT3E)
+#define DOUBLE_PRECISION long double
+#else
+#define DOUBLE_PRECISION double
+#endif
+#endif
+
+#ifndef FORTRAN_REAL
+#if defined(CRAYFortran) && defined(_CRAYT3E)
+#define FORTRAN_REAL double
+#else
+#define FORTRAN_REAL float
+#endif
+#endif
+
+#ifdef CRAYFortran
+#ifdef _CRAY
+#include <fortran.h>
+#else
+#include "fortran.h" /* i.e. if crosscompiling assume user has file. */
+#endif
+#define FLOATVVVVVVV_cfPP (FORTRAN_REAL *) /* Used for C calls FORTRAN. */
+/* CRAY's double==float but CRAY says pointers to doubles and floats are diff.*/
+#define VOIDP (void *) /* When FORTRAN calls C, we don't know if C routine
+ arg.'s have been declared float *, or double *. */
+#else
+#define FLOATVVVVVVV_cfPP
+#define VOIDP
+#endif
+
+#ifdef vmsFortran
+#if defined(vms) || defined(__vms)
+#include <descrip.h>
+#else
+#include "descrip.h" /* i.e. if crosscompiling assume user has file. */
+#endif
+#endif
+
+#ifdef sunFortran
+#if defined(sun) || defined(__sun)
+#include <math.h> /* Sun's FLOATFUNCTIONTYPE, ASSIGNFLOAT, RETURNFLOAT. */
+#else
+#include "math.h" /* i.e. if crosscompiling assume user has file. */
+#endif
+/* At least starting with the default C compiler SC3.0.1 of SunOS 5.3,
+ * FLOATFUNCTIONTYPE, ASSIGNFLOAT, RETURNFLOAT are not required and not in
+ * <math.h>, since sun C no longer promotes C float return values to doubles.
+ * Therefore, only use them if defined.
+ * Even if gcc is being used, assume that it exhibits the Sun C compiler
+ * behavior in order to be able to use *.o from the Sun C compiler.
+ * i.e. If FLOATFUNCTIONTYPE, etc. are in math.h, they required by gcc.
+ */
+#endif
+
+#ifndef apolloFortran
+#define COMMON_BLOCK_DEF(DEFINITION, NAME) extern DEFINITION NAME
+#define CF_NULL_PROTO
+#else /* HP doesn't understand #elif. */
+/* Without ANSI prototyping, Apollo promotes float functions to double. */
+/* Note that VAX/VMS, IBM, Mips choke on 'type function(...);' prototypes. */
+#define CF_NULL_PROTO ...
+#ifndef __CF__APOLLO67
+#define COMMON_BLOCK_DEF(DEFINITION, NAME) \
+ DEFINITION NAME __attribute((__section(NAME)))
+#else
+#define COMMON_BLOCK_DEF(DEFINITION, NAME) \
+ DEFINITION NAME #attribute[section(NAME)]
+#endif
+#endif
+
+#ifdef __cplusplus
+#undef CF_NULL_PROTO
+#define CF_NULL_PROTO ...
+#endif
+
+
+#ifndef USE_NEW_DELETE
+#ifdef __cplusplus
+#define USE_NEW_DELETE 1
+#else
+#define USE_NEW_DELETE 0
+#endif
+#endif
+#if USE_NEW_DELETE
+#define _cf_malloc(N) new char[N]
+#define _cf_free(P) delete[] P
+#else
+#define _cf_malloc(N) (char *)malloc(N)
+#define _cf_free(P) free(P)
+#endif
+
+#ifdef mipsFortran
+#define CF_DECLARE_GETARG int f77argc; char **f77argv
+#define CF_SET_GETARG(ARGC,ARGV) f77argc = ARGC; f77argv = ARGV
+#else
+#define CF_DECLARE_GETARG
+#define CF_SET_GETARG(ARGC,ARGV)
+#endif
+
+#ifdef OLD_VAXC /* Allow %CC-I-PARAMNOTUSED. */
+#pragma standard
+#endif
+
+#define AcfCOMMA ,
+#define AcfCOLON ;
+
+/*-------------------------------------------------------------------------*/
+
+/* UTILITIES USED WITHIN CFORTRAN.H */
+
+#define _cfMIN(A,B) (A<B?A:B)
+
+/* 970211 - XIX.145:
+ firstindexlength - better name is all_but_last_index_lengths
+ secondindexlength - better name is last_index_length
+ */
+#define firstindexlength(A) (sizeof(A[0])==1 ? 1 : (sizeof(A) / sizeof(A[0])) )
+#define secondindexlength(A) (sizeof(A[0])==1 ? sizeof(A) : sizeof(A[0]) )
+
+/* Behavior of FORTRAN LOGICAL. All machines' LOGICAL is same size as C's int.
+Conversion is automatic except for arrays which require F2CLOGICALV/C2FLOGICALV.
+f2c, MIPS f77 [DECstation, SGI], VAX Ultrix f77,
+HP-UX f77 : as in C.
+VAX/VMS FORTRAN, VAX Ultrix fort,
+Absoft Unix Fortran, IBM RS/6000 xlf : LS Bit = 0/1 = TRUE/FALSE.
+Apollo : neg. = TRUE, else FALSE.
+[Apollo accepts -1 as TRUE for function values, but NOT all other neg. values.]
+[DECFortran for Ultrix RISC is also called f77 but is the same as VAX/VMS.]
+[MIPS f77 treats .eqv./.neqv. as .eq./.ne. and hence requires LOGICAL_STRICT.]*/
+
+#if defined(NAGf90Fortran) || defined(f2cFortran) || defined(mipsFortran) || defined(PowerStationFortran) || defined(hpuxFortran800) || defined(AbsoftUNIXFortran) || defined(AbsoftProFortran) || defined(SXFortran)
+/* SX/PowerStationFortran have 0 and 1 defined, others are neither T nor F. */
+/* hpuxFortran800 has 0 and 0x01000000 defined. Others are unknown. */
+#define LOGICAL_STRICT /* Other Fortran have .eqv./.neqv. == .eq./.ne. */
+#endif
+
+#define C2FLOGICALV(A,I) \
+ do {int __i; for(__i=0;__i<I;__i++) A[__i]=C2FLOGICAL(A[__i]); } while (0)
+#define F2CLOGICALV(A,I) \
+ do {int __i; for(__i=0;__i<I;__i++) A[__i]=F2CLOGICAL(A[__i]); } while (0)
+
+#if defined(apolloFortran)
+#define C2FLOGICAL(L) ((L)?-1:(L)&~((unsigned)1<<sizeof(int)*8-1))
+#define F2CLOGICAL(L) ((L)<0?(L):0)
+#else
+#if defined(CRAYFortran)
+#define C2FLOGICAL(L) _btol(L)
+#define F2CLOGICAL(L) _ltob(&(L)) /* Strangely _ltob() expects a pointer. */
+#else
+#if defined(IBMR2Fortran) || defined(vmsFortran) || defined(DECFortran) || defined(AbsoftUNIXFortran)
+/* How come no AbsoftProFortran ? */
+#define C2FLOGICAL(L) ((L)?(L)|1:(L)&~(int)1)
+#define F2CLOGICAL(L) ((L)&1?(L):0)
+#else
+#if defined(CONVEXFortran)
+#define C2FLOGICAL(L) ((L) ? ~0 : 0 )
+#define F2CLOGICAL(L) (L)
+#else /* others evaluate LOGICALs as for C. */
+#define C2FLOGICAL(L) (L)
+#define F2CLOGICAL(L) (L)
+#ifndef LOGICAL_STRICT
+#undef C2FLOGICALV
+#undef F2CLOGICALV
+#define C2FLOGICALV(A,I)
+#define F2CLOGICALV(A,I)
+#endif /* LOGICAL_STRICT */
+#endif /* CONVEXFortran || All Others */
+#endif /* IBMR2Fortran vmsFortran DECFortran AbsoftUNIXFortran */
+#endif /* CRAYFortran */
+#endif /* apolloFortran */
+
+/* 970514 - In addition to CRAY, there may be other machines
+ for which LOGICAL_STRICT makes no sense. */
+#if defined(LOGICAL_STRICT) && !defined(CRAYFortran)
+/* Force C2FLOGICAL to generate only the values for either .TRUE. or .FALSE.
+ SX/PowerStationFortran only have 0 and 1 defined.
+ Elsewhere, only needed if you want to do:
+ logical lvariable
+ if (lvariable .eq. .true.) then ! (1)
+ instead of
+ if (lvariable .eqv. .true.) then ! (2)
+ - (1) may not even be FORTRAN/77 and that Apollo's f77 and IBM's xlf
+ refuse to compile (1), so you are probably well advised to stay away from
+ (1) and from LOGICAL_STRICT.
+ - You pay a (slight) performance penalty for using LOGICAL_STRICT. */
+#undef C2FLOGICAL
+#ifdef hpuxFortran800
+#define C2FLOGICAL(L) ((L)?0x01000000:0)
+#else
+#if defined(apolloFortran) || defined(vmsFortran) || defined(DECFortran)
+#define C2FLOGICAL(L) ((L)?-1:0) /* These machines use -1/0 for .true./.false.*/
+#else
+#define C2FLOGICAL(L) ((L)? 1:0) /* All others use +1/0 for .true./.false.*/
+#endif
+#endif
+#endif /* LOGICAL_STRICT */
+
+/* Convert a vector of C strings into FORTRAN strings. */
+#ifndef __CF__KnR
+static char *c2fstrv(char* cstr, char *fstr, int elem_len, int sizeofcstr)
+#else
+static char *c2fstrv( cstr, fstr, elem_len, sizeofcstr)
+ char* cstr; char *fstr; int elem_len; int sizeofcstr;
+#endif
+{ int i,j;
+/* elem_len includes \0 for C strings. Fortran strings don't have term. \0.
+ Useful size of string must be the same in both languages. */
+for (i=0; i<sizeofcstr/elem_len; i++) {
+ for (j=1; j<elem_len && *cstr; j++) *fstr++ = *cstr++;
+ cstr += 1+elem_len-j;
+ for (; j<elem_len; j++) *fstr++ = ' ';
+} /* 95109 - Seems to be returning the original fstr. */
+return fstr-sizeofcstr+sizeofcstr/elem_len; }
+
+/* Convert a vector of FORTRAN strings into C strings. */
+#ifndef __CF__KnR
+static char *f2cstrv(char *fstr, char* cstr, int elem_len, int sizeofcstr)
+#else
+static char *f2cstrv( fstr, cstr, elem_len, sizeofcstr)
+ char *fstr; char* cstr; int elem_len; int sizeofcstr;
+#endif
+{ int i,j;
+/* elem_len includes \0 for C strings. Fortran strings don't have term. \0.
+ Useful size of string must be the same in both languages. */
+cstr += sizeofcstr;
+fstr += sizeofcstr - sizeofcstr/elem_len;
+for (i=0; i<sizeofcstr/elem_len; i++) {
+ *--cstr = '\0';
+ for (j=1; j<elem_len; j++) *--cstr = *--fstr;
+} return cstr; }
+
+/* kill the trailing char t's in string s. */
+#ifndef __CF__KnR
+static char *kill_trailing(char *s, char t)
+#else
+static char *kill_trailing( s, t) char *s; char t;
+#endif
+{char *e;
+e = s + strlen(s);
+if (e>s) { /* Need this to handle NULL string.*/
+ while (e>s && *--e==t); /* Don't follow t's past beginning. */
+ e[*e==t?0:1] = '\0'; /* Handle s[0]=t correctly. */
+} return s; }
+
+/* kill_trailingn(s,t,e) will kill the trailing t's in string s. e normally
+points to the terminating '\0' of s, but may actually point to anywhere in s.
+s's new '\0' will be placed at e or earlier in order to remove any trailing t's.
+If e<s string s is left unchanged. */
+#ifndef __CF__KnR
+static char *kill_trailingn(char *s, char t, char *e)
+#else
+static char *kill_trailingn( s, t, e) char *s; char t; char *e;
+#endif
+{
+if (e==s) *e = '\0'; /* Kill the string makes sense here.*/
+else if (e>s) { /* Watch out for neg. length string.*/
+ while (e>s && *--e==t); /* Don't follow t's past beginning. */
+ e[*e==t?0:1] = '\0'; /* Handle s[0]=t correctly. */
+} return s; }
+
+/* Note the following assumes that any element which has t's to be chopped off,
+does indeed fill the entire element. */
+#ifndef __CF__KnR
+static char *vkill_trailing(char* cstr, int elem_len, int sizeofcstr, char t)
+#else
+static char *vkill_trailing( cstr, elem_len, sizeofcstr, t)
+ char* cstr; int elem_len; int sizeofcstr; char t;
+#endif
+{ int i;
+for (i=0; i<sizeofcstr/elem_len; i++) /* elem_len includes \0 for C strings. */
+ kill_trailingn(cstr+elem_len*i,t,cstr+elem_len*(i+1)-1);
+return cstr; }
+
+#ifdef vmsFortran
+typedef struct dsc$descriptor_s fstring;
+#define DSC$DESCRIPTOR_A(DIMCT) \
+struct { \
+ unsigned short dsc$w_length; unsigned char dsc$b_dtype; \
+ unsigned char dsc$b_class; char *dsc$a_pointer; \
+ char dsc$b_scale; unsigned char dsc$b_digits; \
+ struct { \
+ unsigned : 3; unsigned dsc$v_fl_binscale : 1; \
+ unsigned dsc$v_fl_redim : 1; unsigned dsc$v_fl_column : 1; \
+ unsigned dsc$v_fl_coeff : 1; unsigned dsc$v_fl_bounds : 1; \
+ } dsc$b_aflags; \
+ unsigned char dsc$b_dimct; unsigned long dsc$l_arsize; \
+ char *dsc$a_a0; long dsc$l_m [DIMCT]; \
+ struct { \
+ long dsc$l_l; long dsc$l_u; \
+ } dsc$bounds [DIMCT]; \
+}
+typedef DSC$DESCRIPTOR_A(1) fstringvector;
+/*typedef DSC$DESCRIPTOR_A(2) fstringarrarr;
+ typedef DSC$DESCRIPTOR_A(3) fstringarrarrarr;*/
+#define initfstr(F,C,ELEMNO,ELEMLEN) \
+( (F).dsc$l_arsize= ( (F).dsc$w_length =(ELEMLEN) ) \
+ *( (F).dsc$l_m[0]=(F).dsc$bounds[0].dsc$l_u=(ELEMNO) ), \
+ (F).dsc$a_a0 = ( (F).dsc$a_pointer=(C) ) - (F).dsc$w_length ,(F))
+
+#else
+#define _NUM_ELEMS -1
+#define _NUM_ELEM_ARG -2
+#define NUM_ELEMS(A) A,_NUM_ELEMS
+#define NUM_ELEM_ARG(B) *_2(A,B),_NUM_ELEM_ARG
+#define TERM_CHARS(A,B) A,B
+#ifndef __CF__KnR
+static int num_elem(char *strv, unsigned elem_len, int term_char, int num_term)
+#else
+static int num_elem( strv, elem_len, term_char, num_term)
+ char *strv; unsigned elem_len; int term_char; int num_term;
+#endif
+/* elem_len is the number of characters in each element of strv, the FORTRAN
+vector of strings. The last element of the vector must begin with at least
+num_term term_char characters, so that this routine can determine how
+many elements are in the vector. */
+{
+unsigned num,i;
+if (num_term == _NUM_ELEMS || num_term == _NUM_ELEM_ARG)
+ return term_char;
+if (num_term <=0) num_term = (int)elem_len;
+for (num=0; ; num++) {
+ for (i=0; i<(unsigned)num_term && *strv==term_char; i++,strv++);
+ if (i==(unsigned)num_term) break;
+ else strv += elem_len-i;
+}
+return (int)num;
+}
+#endif
+/*-------------------------------------------------------------------------*/
+
+/* UTILITIES FOR C TO USE STRINGS IN FORTRAN COMMON BLOCKS */
+
+/* C string TO Fortran Common Block STRing. */
+/* DIM is the number of DIMensions of the array in terms of strings, not
+ characters. e.g. char a[12] has DIM = 0, char a[12][4] has DIM = 1, etc. */
+#define C2FCBSTR(CSTR,FSTR,DIM) \
+ c2fstrv((char *)CSTR, (char *)FSTR, sizeof(FSTR)/cfelementsof(FSTR,DIM)+1, \
+ sizeof(FSTR)+cfelementsof(FSTR,DIM))
+
+/* Fortran Common Block string TO C STRing. */
+#define FCB2CSTR(FSTR,CSTR,DIM) \
+ vkill_trailing(f2cstrv((char *)FSTR, (char *)CSTR, \
+ sizeof(FSTR)/cfelementsof(FSTR,DIM)+1, \
+ sizeof(FSTR)+cfelementsof(FSTR,DIM)), \
+ sizeof(FSTR)/cfelementsof(FSTR,DIM)+1, \
+ sizeof(FSTR)+cfelementsof(FSTR,DIM), ' ')
+
+#define cfDEREFERENCE0
+#define cfDEREFERENCE1 *
+#define cfDEREFERENCE2 **
+#define cfDEREFERENCE3 ***
+#define cfDEREFERENCE4 ****
+#define cfDEREFERENCE5 *****
+#define cfelementsof(A,D) (sizeof(A)/sizeof(_(cfDEREFERENCE,D)(A)))
+
+/*-------------------------------------------------------------------------*/
+
+/* UTILITIES FOR C TO CALL FORTRAN SUBROUTINES */
+
+/* Define lookup tables for how to handle the various types of variables. */
+
+#ifdef OLD_VAXC /* Prevent %CC-I-PARAMNOTUSED. */
+#pragma nostandard
+#endif
+
+#define ZTRINGV_NUM(I) I
+#define ZTRINGV_ARGFP(I) (*(_2(A,I))) /* Undocumented. For PINT, etc. */
+#define ZTRINGV_ARGF(I) _2(A,I)
+#ifdef CFSUBASFUN
+#define ZTRINGV_ARGS(I) ZTRINGV_ARGF(I)
+#else
+#define ZTRINGV_ARGS(I) _2(B,I)
+#endif
+
+#define PBYTE_cfVP(A,B) PINT_cfVP(A,B)
+#define PDOUBLE_cfVP(A,B)
+#define PFLOAT_cfVP(A,B)
+#ifdef ZTRINGV_ARGS_allows_Pvariables
+/* This allows Pvariables for ARGS. ARGF machinery is above ARGFP.
+ * B is not needed because the variable may be changed by the Fortran routine,
+ * but because B is the only way to access an arbitrary macro argument. */
+#define PINT_cfVP(A,B) int B = (int)A; /* For ZSTRINGV_ARGS */
+#else
+#define PINT_cfVP(A,B)
+#endif
+#define PLOGICAL_cfVP(A,B) int *B; /* Returning LOGICAL in FUNn and SUBn */
+#define PLONG_cfVP(A,B) PINT_cfVP(A,B)
+#define PSHORT_cfVP(A,B) PINT_cfVP(A,B)
+
+#define VCF_INT_S(T,A,B) _(T,VVVVVVV_cfTYPE) B = A;
+#define VCF_INT_F(T,A,B) _(T,_cfVCF)(A,B)
+/* _cfVCF table is directly mapped to _cfCCC table. */
+#define BYTE_cfVCF(A,B)
+#define DOUBLE_cfVCF(A,B)
+#if !defined(__CF__KnR)
+#define FLOAT_cfVCF(A,B)
+#else
+#define FLOAT_cfVCF(A,B) FORTRAN_REAL B = A;
+#endif
+#define INT_cfVCF(A,B)
+#define LOGICAL_cfVCF(A,B)
+#define LONG_cfVCF(A,B)
+#define SHORT_cfVCF(A,B)
+
+/* 980416
+ Cast (void (*)(CF_NULL_PROTO)) causes SunOS CC 4.2 occasionally to barf,
+ while the following equivalent typedef is fine.
+ For consistency use the typedef on all machines.
+ */
+typedef void (*cfCAST_FUNCTION)(CF_NULL_PROTO);
+
+#define VCF(TN,I) _Icf4(4,V,TN,_(A,I),_(B,I),F)
+#define VVCF(TN,AI,BI) _Icf4(4,V,TN,AI,BI,S)
+#define INT_cfV(T,A,B,F) _(VCF_INT_,F)(T,A,B)
+#define INTV_cfV(T,A,B,F)
+#define INTVV_cfV(T,A,B,F)
+#define INTVVV_cfV(T,A,B,F)
+#define INTVVVV_cfV(T,A,B,F)
+#define INTVVVVV_cfV(T,A,B,F)
+#define INTVVVVVV_cfV(T,A,B,F)
+#define INTVVVVVVV_cfV(T,A,B,F)
+#define PINT_cfV( T,A,B,F) _(T,_cfVP)(A,B)
+#define PVOID_cfV( T,A,B,F)
+#if defined(apolloFortran) || defined(hpuxFortran800) || defined(AbsoftUNIXFortran) || defined(AbsoftProFortran)
+#define ROUTINE_cfV(T,A,B,F) void (*B)(CF_NULL_PROTO) = (cfCAST_FUNCTION)A;
+#else
+#define ROUTINE_cfV(T,A,B,F)
+#endif
+#define SIMPLE_cfV(T,A,B,F)
+#ifdef vmsFortran
+#define STRING_cfV(T,A,B,F) static struct {fstring f; unsigned clen;} B = \
+ {{0,DSC$K_DTYPE_T,DSC$K_CLASS_S,NULL},0};
+#define PSTRING_cfV(T,A,B,F) static fstring B={0,DSC$K_DTYPE_T,DSC$K_CLASS_S,NULL};
+#define STRINGV_cfV(T,A,B,F) static fstringvector B = \
+ {sizeof(A),DSC$K_DTYPE_T,DSC$K_CLASS_A,NULL,0,0,{0,0,1,1,1},1,0,NULL,0,{1,0}};
+#define PSTRINGV_cfV(T,A,B,F) static fstringvector B = \
+ {0,DSC$K_DTYPE_T,DSC$K_CLASS_A,NULL,0,0,{0,0,1,1,1},1,0,NULL,0,{1,0}};
+#else
+#define STRING_cfV(T,A,B,F) struct {unsigned int clen, flen;} B;
+#define STRINGV_cfV(T,A,B,F) struct {char *s, *fs; unsigned flen;} B;
+#define PSTRING_cfV(T,A,B,F) int B;
+#define PSTRINGV_cfV(T,A,B,F) struct{char *fs; unsigned int sizeofA,flen;}B;
+#endif
+#define ZTRINGV_cfV(T,A,B,F) STRINGV_cfV(T,A,B,F)
+#define PZTRINGV_cfV(T,A,B,F) PSTRINGV_cfV(T,A,B,F)
+
+/* Note that the actions of the A table were performed inside the AA table.
+ VAX Ultrix vcc, and HP-UX cc, didn't evaluate arguments to functions left to
+ right, so we had to split the original table into the current robust two. */
+#define ACF(NAME,TN,AI,I) _(TN,_cfSTR)(4,A,NAME,I,AI,_(B,I),0)
+#define DEFAULT_cfA(M,I,A,B)
+#define LOGICAL_cfA(M,I,A,B) B=C2FLOGICAL(B);
+#define PLOGICAL_cfA(M,I,A,B) A=C2FLOGICAL(A);
+#define STRING_cfA(M,I,A,B) STRING_cfC(M,I,A,B,sizeof(A))
+#define PSTRING_cfA(M,I,A,B) PSTRING_cfC(M,I,A,B,sizeof(A))
+#ifdef vmsFortran
+#define AATRINGV_cfA( A,B, sA,filA,silA) \
+ initfstr(B,_cf_malloc((sA)-(filA)),(filA),(silA)-1), \
+ c2fstrv(A,B.dsc$a_pointer,(silA),(sA));
+#define APATRINGV_cfA( A,B, sA,filA,silA) \
+ initfstr(B,A,(filA),(silA)-1),c2fstrv(A,A,(silA),(sA));
+#else
+#define AATRINGV_cfA( A,B, sA,filA,silA) \
+ (B.s=_cf_malloc((sA)-(filA)),B.fs=c2fstrv(A,B.s,(B.flen=(silA)-1)+1,(sA)));
+#define APATRINGV_cfA( A,B, sA,filA,silA) \
+ B.fs=c2fstrv(A,A,(B.flen=(silA)-1)+1,B.sizeofA=(sA));
+#endif
+#define STRINGV_cfA(M,I,A,B) \
+ AATRINGV_cfA((char *)A,B,sizeof(A),firstindexlength(A),secondindexlength(A))
+#define PSTRINGV_cfA(M,I,A,B) \
+ APATRINGV_cfA((char *)A,B,sizeof(A),firstindexlength(A),secondindexlength(A))
+#define ZTRINGV_cfA(M,I,A,B) AATRINGV_cfA( (char *)A,B, \
+ (_3(M,_ELEMS_,I))*(( _3(M,_ELEMLEN_,I))+1), \
+ (_3(M,_ELEMS_,I)),(_3(M,_ELEMLEN_,I))+1)
+#define PZTRINGV_cfA(M,I,A,B) APATRINGV_cfA( (char *)A,B, \
+ (_3(M,_ELEMS_,I))*(( _3(M,_ELEMLEN_,I))+1), \
+ (_3(M,_ELEMS_,I)),(_3(M,_ELEMLEN_,I))+1)
+
+#define PBYTE_cfAAP(A,B) &A
+#define PDOUBLE_cfAAP(A,B) &A
+#define PFLOAT_cfAAP(A,B) FLOATVVVVVVV_cfPP &A
+#define PINT_cfAAP(A,B) &A
+#define PLOGICAL_cfAAP(A,B) B= &A /* B used to keep a common W table. */
+#define PLONG_cfAAP(A,B) &A
+#define PSHORT_cfAAP(A,B) &A
+
+#define AACF(TN,AI,I,C) _SEP_(TN,C,cfCOMMA) _Icf(3,AA,TN,AI,_(B,I))
+#define INT_cfAA(T,A,B) &B
+#define INTV_cfAA(T,A,B) _(T,VVVVVV_cfPP) A
+#define INTVV_cfAA(T,A,B) _(T,VVVVV_cfPP) A[0]
+#define INTVVV_cfAA(T,A,B) _(T,VVVV_cfPP) A[0][0]
+#define INTVVVV_cfAA(T,A,B) _(T,VVV_cfPP) A[0][0][0]
+#define INTVVVVV_cfAA(T,A,B) _(T,VV_cfPP) A[0][0][0][0]
+#define INTVVVVVV_cfAA(T,A,B) _(T,V_cfPP) A[0][0][0][0][0]
+#define INTVVVVVVV_cfAA(T,A,B) _(T,_cfPP) A[0][0][0][0][0][0]
+#define PINT_cfAA(T,A,B) _(T,_cfAAP)(A,B)
+#define PVOID_cfAA(T,A,B) (void *) A
+#if defined(apolloFortran) || defined(hpuxFortran800) || defined(AbsoftUNIXFortran)
+#define ROUTINE_cfAA(T,A,B) &B
+#else
+#define ROUTINE_cfAA(T,A,B) (cfCAST_FUNCTION)A
+#endif
+#define STRING_cfAA(T,A,B) STRING_cfCC(T,A,B)
+#define PSTRING_cfAA(T,A,B) PSTRING_cfCC(T,A,B)
+#ifdef vmsFortran
+#define STRINGV_cfAA(T,A,B) &B
+#else
+#ifdef CRAYFortran
+#define STRINGV_cfAA(T,A,B) _cptofcd(B.fs,B.flen)
+#else
+#define STRINGV_cfAA(T,A,B) B.fs
+#endif
+#endif
+#define PSTRINGV_cfAA(T,A,B) STRINGV_cfAA(T,A,B)
+#define ZTRINGV_cfAA(T,A,B) STRINGV_cfAA(T,A,B)
+#define PZTRINGV_cfAA(T,A,B) STRINGV_cfAA(T,A,B)
+
+#if defined(vmsFortran) || defined(CRAYFortran)
+#define JCF(TN,I)
+#define KCF(TN,I)
+#else
+#define JCF(TN,I) _(TN,_cfSTR)(1,J,_(B,I), 0,0,0,0)
+#if defined(AbsoftUNIXFortran)
+#define DEFAULT_cfJ(B) ,0
+#else
+#define DEFAULT_cfJ(B)
+#endif
+#define LOGICAL_cfJ(B) DEFAULT_cfJ(B)
+#define PLOGICAL_cfJ(B) DEFAULT_cfJ(B)
+#define STRING_cfJ(B) ,B.flen
+#define PSTRING_cfJ(B) ,B
+#define STRINGV_cfJ(B) STRING_cfJ(B)
+#define PSTRINGV_cfJ(B) STRING_cfJ(B)
+#define ZTRINGV_cfJ(B) STRING_cfJ(B)
+#define PZTRINGV_cfJ(B) STRING_cfJ(B)
+
+/* KCF is identical to DCF, except that KCF ZTRING is not empty. */
+#define KCF(TN,I) _(TN,_cfSTR)(1,KK,_(B,I), 0,0,0,0)
+#if defined(AbsoftUNIXFortran)
+#define DEFAULT_cfKK(B) , unsigned B
+#else
+#define DEFAULT_cfKK(B)
+#endif
+#define LOGICAL_cfKK(B) DEFAULT_cfKK(B)
+#define PLOGICAL_cfKK(B) DEFAULT_cfKK(B)
+#define STRING_cfKK(B) , unsigned B
+#define PSTRING_cfKK(B) STRING_cfKK(B)
+#define STRINGV_cfKK(B) STRING_cfKK(B)
+#define PSTRINGV_cfKK(B) STRING_cfKK(B)
+#define ZTRINGV_cfKK(B) STRING_cfKK(B)
+#define PZTRINGV_cfKK(B) STRING_cfKK(B)
+#endif
+
+#define WCF(TN,AN,I) _(TN,_cfSTR)(2,W,AN,_(B,I), 0,0,0)
+#define DEFAULT_cfW(A,B)
+#define LOGICAL_cfW(A,B)
+#define PLOGICAL_cfW(A,B) *B=F2CLOGICAL(*B);
+#define STRING_cfW(A,B) (A[B.clen]!='\0'?A[B.clen]='\0':0); /* A?="constnt"*/
+#define PSTRING_cfW(A,B) kill_trailing(A,' ');
+#ifdef vmsFortran
+#define STRINGV_cfW(A,B) _cf_free(B.dsc$a_pointer);
+#define PSTRINGV_cfW(A,B) \
+ vkill_trailing(f2cstrv((char*)A, (char*)A, \
+ B.dsc$w_length+1, B.dsc$l_arsize+B.dsc$l_m[0]), \
+ B.dsc$w_length+1, B.dsc$l_arsize+B.dsc$l_m[0], ' ');
+#else
+#define STRINGV_cfW(A,B) _cf_free(B.s);
+#define PSTRINGV_cfW(A,B) vkill_trailing( \
+ f2cstrv((char*)A,(char*)A,B.flen+1,B.sizeofA), B.flen+1,B.sizeofA,' ');
+#endif
+#define ZTRINGV_cfW(A,B) STRINGV_cfW(A,B)
+#define PZTRINGV_cfW(A,B) PSTRINGV_cfW(A,B)
+
+#define NCF(TN,I,C) _SEP_(TN,C,cfCOMMA) _Icf(2,N,TN,_(A,I),0)
+#define NNCF(TN,I,C) UUCF(TN,I,C)
+#define NNNCF(TN,I,C) _SEP_(TN,C,cfCOLON) _Icf(2,N,TN,_(A,I),0)
+#define INT_cfN(T,A) _(T,VVVVVVV_cfTYPE) * A
+#define INTV_cfN(T,A) _(T,VVVVVV_cfTYPE) * A
+#define INTVV_cfN(T,A) _(T,VVVVV_cfTYPE) * A
+#define INTVVV_cfN(T,A) _(T,VVVV_cfTYPE) * A
+#define INTVVVV_cfN(T,A) _(T,VVV_cfTYPE) * A
+#define INTVVVVV_cfN(T,A) _(T,VV_cfTYPE) * A
+#define INTVVVVVV_cfN(T,A) _(T,V_cfTYPE) * A
+#define INTVVVVVVV_cfN(T,A) _(T,_cfTYPE) * A
+#define PINT_cfN(T,A) _(T,_cfTYPE) * A
+#define PVOID_cfN(T,A) void * A
+#if defined(apolloFortran) || defined(hpuxFortran800) || defined(AbsoftUNIXFortran)
+#define ROUTINE_cfN(T,A) void (**A)(CF_NULL_PROTO)
+#else
+#define ROUTINE_cfN(T,A) void ( *A)(CF_NULL_PROTO)
+#endif
+#ifdef vmsFortran
+#define STRING_cfN(T,A) fstring * A
+#define STRINGV_cfN(T,A) fstringvector * A
+#else
+#ifdef CRAYFortran
+#define STRING_cfN(T,A) _fcd A
+#define STRINGV_cfN(T,A) _fcd A
+#else
+#define STRING_cfN(T,A) char * A
+#define STRINGV_cfN(T,A) char * A
+#endif
+#endif
+#define PSTRING_cfN(T,A) STRING_cfN(T,A) /* CRAY insists on arg.'s here. */
+#define PNSTRING_cfN(T,A) STRING_cfN(T,A) /* CRAY insists on arg.'s here. */
+#define PPSTRING_cfN(T,A) STRING_cfN(T,A) /* CRAY insists on arg.'s here. */
+#define PSTRINGV_cfN(T,A) STRINGV_cfN(T,A)
+#define ZTRINGV_cfN(T,A) STRINGV_cfN(T,A)
+#define PZTRINGV_cfN(T,A) PSTRINGV_cfN(T,A)
+
+
+/* Apollo 6.7, CRAY, old Sun, VAX/Ultrix vcc/cc and new ultrix
+ can't hack more than 31 arg's.
+ e.g. ultrix >= 4.3 gives message:
+ zow35> cc -c -DDECFortran cfortest.c
+ cfe: Fatal: Out of memory: cfortest.c
+ zow35>
+ Old __hpux had the problem, but new 'HP-UX A.09.03 A 9000/735' is fine
+ if using -Aa, otherwise we have a problem.
+ */
+#ifndef MAX_PREPRO_ARGS
+#if !defined(__GNUC__) && (defined(VAXUltrix) || defined(__CF__APOLLO67) || (defined(sun)&&!defined(__sun)) || defined(_CRAY) || defined(__ultrix__) || (defined(__hpux)&&defined(__CF__KnR)))
+#define MAX_PREPRO_ARGS 31
+#else
+#define MAX_PREPRO_ARGS 99
+#endif
+#endif
+
+#if defined(AbsoftUNIXFortran) || defined(AbsoftProFortran)
+/* In addition to explicit Absoft stuff, only Absoft requires:
+ - DEFAULT coming from _cfSTR.
+ DEFAULT could have been called e.g. INT, but keep it for clarity.
+ - M term in CFARGT14 and CFARGT14FS.
+ */
+#define ABSOFT_cf1(T0) _(T0,_cfSTR)(0,ABSOFT1,0,0,0,0,0)
+#define ABSOFT_cf2(T0) _(T0,_cfSTR)(0,ABSOFT2,0,0,0,0,0)
+#define ABSOFT_cf3(T0) _(T0,_cfSTR)(0,ABSOFT3,0,0,0,0,0)
+#define DEFAULT_cfABSOFT1
+#define LOGICAL_cfABSOFT1
+#define STRING_cfABSOFT1 ,MAX_LEN_FORTRAN_FUNCTION_STRING
+#define DEFAULT_cfABSOFT2
+#define LOGICAL_cfABSOFT2
+#define STRING_cfABSOFT2 ,unsigned D0
+#define DEFAULT_cfABSOFT3
+#define LOGICAL_cfABSOFT3
+#define STRING_cfABSOFT3 ,D0
+#else
+#define ABSOFT_cf1(T0)
+#define ABSOFT_cf2(T0)
+#define ABSOFT_cf3(T0)
+#endif
+
+/* _Z introduced to cicumvent IBM and HP silly preprocessor warning.
+ e.g. "Macro CFARGT14 invoked with a null argument."
+ */
+#define _Z
+
+#define CFARGT14S(S,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
+ S(T1,1) S(T2,2) S(T3,3) S(T4,4) S(T5,5) S(T6,6) S(T7,7) \
+ S(T8,8) S(T9,9) S(TA,10) S(TB,11) S(TC,12) S(TD,13) S(TE,14)
+#define CFARGT27S(S,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR) \
+ S(T1,1) S(T2,2) S(T3,3) S(T4,4) S(T5,5) S(T6,6) S(T7,7) \
+ S(T8,8) S(T9,9) S(TA,10) S(TB,11) S(TC,12) S(TD,13) S(TE,14) \
+ S(TF,15) S(TG,16) S(TH,17) S(TI,18) S(TJ,19) S(TK,20) S(TL,21) \
+ S(TM,22) S(TN,23) S(TO,24) S(TP,25) S(TQ,26) S(TR,27)
+
+#define CFARGT14FS(F,S,M,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
+ F(T1,1,0) F(T2,2,1) F(T3,3,1) F(T4,4,1) F(T5,5,1) F(T6,6,1) F(T7,7,1) \
+ F(T8,8,1) F(T9,9,1) F(TA,10,1) F(TB,11,1) F(TC,12,1) F(TD,13,1) F(TE,14,1) \
+ M CFARGT14S(S,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE)
+#define CFARGT27FS(F,S,M,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR) \
+ F(T1,1,0) F(T2,2,1) F(T3,3,1) F(T4,4,1) F(T5,5,1) F(T6,6,1) F(T7,7,1) \
+ F(T8,8,1) F(T9,9,1) F(TA,10,1) F(TB,11,1) F(TC,12,1) F(TD,13,1) F(TE,14,1) \
+ F(TF,15,1) F(TG,16,1) F(TH,17,1) F(TI,18,1) F(TJ,19,1) F(TK,20,1) F(TL,21,1) \
+ F(TM,22,1) F(TN,23,1) F(TO,24,1) F(TP,25,1) F(TQ,26,1) F(TR,27,1) \
+ M CFARGT27S(S,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR)
+
+#if !(defined(PowerStationFortran)||defined(hpuxFortran800))
+/* Old CFARGT14 -> CFARGT14FS as seen below, for Absoft cross-compile yields:
+ SunOS> cc -c -Xa -DAbsoftUNIXFortran c.c
+ "c.c", line 406: warning: argument mismatch
+ Haven't checked if this is ANSI C or a SunOS bug. SunOS -Xs works ok.
+ Behavior is most clearly seen in example:
+ #define A 1 , 2
+ #define C(X,Y,Z) x=X. y=Y. z=Z.
+ #define D(X,Y,Z) C(X,Y,Z)
+ D(x,A,z)
+ Output from preprocessor is: x = x . y = 1 . z = 2 .
+ #define CFARGT14(F,S,M,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
+ CFARGT14FS(F,S,M,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE)
+*/
+#define CFARGT14(F,S,M,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
+ F(T1,1,0) F(T2,2,1) F(T3,3,1) F(T4,4,1) F(T5,5,1) F(T6,6,1) F(T7,7,1) \
+ F(T8,8,1) F(T9,9,1) F(TA,10,1) F(TB,11,1) F(TC,12,1) F(TD,13,1) F(TE,14,1) \
+ M CFARGT14S(S,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE)
+#define CFARGT27(F,S,M,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR) \
+ F(T1,1,0) F(T2,2,1) F(T3,3,1) F(T4,4,1) F(T5,5,1) F(T6,6,1) F(T7,7,1) \
+ F(T8,8,1) F(T9,9,1) F(TA,10,1) F(TB,11,1) F(TC,12,1) F(TD,13,1) F(TE,14,1) \
+ F(TF,15,1) F(TG,16,1) F(TH,17,1) F(TI,18,1) F(TJ,19,1) F(TK,20,1) F(TL,21,1) \
+ F(TM,22,1) F(TN,23,1) F(TO,24,1) F(TP,25,1) F(TQ,26,1) F(TR,27,1) \
+ M CFARGT27S(S,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR)
+
+#define CFARGT20(F,S,M,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK) \
+ F(T1,1,0) F(T2,2,1) F(T3,3,1) F(T4,4,1) F(T5,5,1) F(T6,6,1) F(T7,7,1) \
+ F(T8,8,1) F(T9,9,1) F(TA,10,1) F(TB,11,1) F(TC,12,1) F(TD,13,1) F(TE,14,1) \
+ F(TF,15,1) F(TG,16,1) F(TH,17,1) F(TI,18,1) F(TJ,19,1) F(TK,20,1) \
+ S(T1,1) S(T2,2) S(T3,3) S(T4,4) S(T5,5) S(T6,6) S(T7,7) \
+ S(T8,8) S(T9,9) S(TA,10) S(TB,11) S(TC,12) S(TD,13) S(TE,14) \
+ S(TF,15) S(TG,16) S(TH,17) S(TI,18) S(TJ,19) S(TK,20)
+#define CFARGTA14(F,S,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE) \
+ F(T1,A1,1,0) F(T2,A2,2,1) F(T3,A3,3,1) F(T4,A4,4,1) F(T5,A5,5,1) F(T6,A6,6,1) \
+ F(T7,A7,7,1) F(T8,A8,8,1) F(T9,A9,9,1) F(TA,AA,10,1) F(TB,AB,11,1) F(TC,AC,12,1) \
+ F(TD,AD,13,1) F(TE,AE,14,1) S(T1,1) S(T2,2) S(T3,3) S(T4,4) \
+ S(T5,5) S(T6,6) S(T7,7) S(T8,8) S(T9,9) S(TA,10) \
+ S(TB,11) S(TC,12) S(TD,13) S(TE,14)
+#if MAX_PREPRO_ARGS>31
+#define CFARGTA20(F,S,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK) \
+ F(T1,A1,1,0) F(T2,A2,2,1) F(T3,A3,3,1) F(T4,A4,4,1) F(T5,A5,5,1) F(T6,A6,6,1) \
+ F(T7,A7,7,1) F(T8,A8,8,1) F(T9,A9,9,1) F(TA,AA,10,1) F(TB,AB,11,1) F(TC,AC,12,1) \
+ F(TD,AD,13,1) F(TE,AE,14,1) F(TF,AF,15,1) F(TG,AG,16,1) F(TH,AH,17,1) F(TI,AI,18,1) \
+ F(TJ,AJ,19,1) F(TK,AK,20,1) S(T1,1) S(T2,2) S(T3,3) S(T4,4) \
+ S(T5,5) S(T6,6) S(T7,7) S(T8,8) S(T9,9) S(TA,10) \
+ S(TB,11) S(TC,12) S(TD,13) S(TE,14) S(TF,15) S(TG,16) \
+ S(TH,17) S(TI,18) S(TJ,19) S(TK,20)
+#define CFARGTA27(F,S,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN,AO,AP,AQ,AR) \
+ F(T1,A1,1,0) F(T2,A2,2,1) F(T3,A3,3,1) F(T4,A4,4,1) F(T5,A5,5,1) F(T6,A6,6,1) \
+ F(T7,A7,7,1) F(T8,A8,8,1) F(T9,A9,9,1) F(TA,AA,10,1) F(TB,AB,11,1) F(TC,AC,12,1) \
+ F(TD,AD,13,1) F(TE,AE,14,1) F(TF,AF,15,1) F(TG,AG,16,1) F(TH,AH,17,1) F(TI,AI,18,1) \
+ F(TJ,AJ,19,1) F(TK,AK,20,1) F(TL,AL,21,1) F(TM,AM,22,1) F(TN,AN,23,1) F(TO,AO,24,1) \
+ F(TP,AP,25,1) F(TQ,AQ,26,1) F(TR,AR,27,1) S(T1,1) S(T2,2) S(T3,3) \
+ S(T4,4) S(T5,5) S(T6,6) S(T7,7) S(T8,8) S(T9,9) \
+ S(TA,10) S(TB,11) S(TC,12) S(TD,13) S(TE,14) S(TF,15) \
+ S(TG,16) S(TH,17) S(TI,18) S(TJ,19) S(TK,20) S(TL,21) \
+ S(TM,22) S(TN,23) S(TO,24) S(TP,25) S(TQ,26) S(TR,27)
+#endif
+#else
+#define CFARGT14(F,S,M,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
+ F(T1,1,0) S(T1,1) F(T2,2,1) S(T2,2) F(T3,3,1) S(T3,3) F(T4,4,1) S(T4,4) \
+ F(T5,5,1) S(T5,5) F(T6,6,1) S(T6,6) F(T7,7,1) S(T7,7) F(T8,8,1) S(T8,8) \
+ F(T9,9,1) S(T9,9) F(TA,10,1) S(TA,10) F(TB,11,1) S(TB,11) F(TC,12,1) S(TC,12) \
+ F(TD,13,1) S(TD,13) F(TE,14,1) S(TE,14)
+#define CFARGT27(F,S,M,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR) \
+ F(T1,1,0) S(T1,1) F(T2,2,1) S(T2,2) F(T3,3,1) S(T3,3) F(T4,4,1) S(T4,4) \
+ F(T5,5,1) S(T5,5) F(T6,6,1) S(T6,6) F(T7,7,1) S(T7,7) F(T8,8,1) S(T8,8) \
+ F(T9,9,1) S(T9,9) F(TA,10,1) S(TA,10) F(TB,11,1) S(TB,11) F(TC,12,1) S(TC,12) \
+ F(TD,13,1) S(TD,13) F(TE,14,1) S(TE,14) F(TF,15,1) S(TF,15) F(TG,16,1) S(TG,16) \
+ F(TH,17,1) S(TH,17) F(TI,18,1) S(TI,18) F(TJ,19,1) S(TJ,19) F(TK,20,1) S(TK,20) \
+ F(TL,21,1) S(TL,21) F(TM,22,1) S(TM,22) F(TN,23,1) S(TN,23) F(TO,24,1) S(TO,24) \
+ F(TP,25,1) S(TP,25) F(TQ,26,1) S(TQ,26) F(TR,27,1) S(TR,27)
+
+#define CFARGT20(F,S,M,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK) \
+ F(T1,1,0) S(T1,1) F(T2,2,1) S(T2,2) F(T3,3,1) S(T3,3) F(T4,4,1) S(T4,4) \
+ F(T5,5,1) S(T5,5) F(T6,6,1) S(T6,6) F(T7,7,1) S(T7,7) F(T8,8,1) S(T8,8) \
+ F(T9,9,1) S(T9,9) F(TA,10,1) S(TA,10) F(TB,11,1) S(TB,11) F(TC,12,1) S(TC,12) \
+ F(TD,13,1) S(TD,13) F(TE,14,1) S(TE,14) F(TF,15,1) S(TF,15) F(TG,16,1) S(TG,16) \
+ F(TH,17,1) S(TH,17) F(TI,18,1) S(TI,18) F(TJ,19,1) S(TJ,19) F(TK,20,1) S(TK,20)
+#define CFARGTA14(F,S,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE) \
+ F(T1,A1,1,0) S(T1,1) F(T2,A2,2,1) S(T2,2) F(T3,A3,3,1) S(T3,3) \
+ F(T4,A4,4,1) S(T4,4) F(T5,A5,5,1) S(T5,5) F(T6,A6,6,1) S(T6,6) \
+ F(T7,A7,7,1) S(T7,7) F(T8,A8,8,1) S(T8,8) F(T9,A9,9,1) S(T9,9) \
+ F(TA,AA,10,1) S(TA,10) F(TB,AB,11,1) S(TB,11) F(TC,AC,12,1) S(TC,12) \
+ F(TD,AD,13,1) S(TD,13) F(TE,AE,14,1) S(TE,14)
+#if MAX_PREPRO_ARGS>31
+#define CFARGTA20(F,S,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK) \
+ F(T1,A1,1,0) S(T1,1) F(T2,A2,2,1) S(T2,2) F(T3,A3,3,1) S(T3,3) \
+ F(T4,A4,4,1) S(T4,4) F(T5,A5,5,1) S(T5,5) F(T6,A6,6,1) S(T6,6) \
+ F(T7,A7,7,1) S(T7,7) F(T8,A8,8,1) S(T8,8) F(T9,A9,9,1) S(T9,9) \
+ F(TA,AA,10,1) S(TA,10) F(TB,AB,11,1) S(TB,11) F(TC,AC,12,1) S(TC,12) \
+ F(TD,AD,13,1) S(TD,13) F(TE,AE,14,1) S(TE,14) F(TF,AF,15,1) S(TF,15) \
+ F(TG,AG,16,1) S(TG,16) F(TH,AH,17,1) S(TH,17) F(TI,AI,18,1) S(TI,18) \
+ F(TJ,AJ,19,1) S(TJ,19) F(TK,AK,20,1) S(TK,20)
+#define CFARGTA27(F,S,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN,AO,AP,AQ,AR) \
+ F(T1,A1,1,0) S(T1,1) F(T2,A2,2,1) S(T2,2) F(T3,A3,3,1) S(T3,3) \
+ F(T4,A4,4,1) S(T4,4) F(T5,A5,5,1) S(T5,5) F(T6,A6,6,1) S(T6,6) \
+ F(T7,A7,7,1) S(T7,7) F(T8,A8,8,1) S(T8,8) F(T9,A9,9,1) S(T9,9) \
+ F(TA,AA,10,1) S(TA,10) F(TB,AB,11,1) S(TB,11) F(TC,AC,12,1) S(TC,12) \
+ F(TD,AD,13,1) S(TD,13) F(TE,AE,14,1) S(TE,14) F(TF,AF,15,1) S(TF,15) \
+ F(TG,AG,16,1) S(TG,16) F(TH,AH,17,1) S(TH,17) F(TI,AI,18,1) S(TI,18) \
+ F(TJ,AJ,19,1) S(TJ,19) F(TK,AK,20,1) S(TK,20) F(TL,AL,21,1) S(TL,21) \
+ F(TM,AM,22,1) S(TM,22) F(TN,AN,23,1) S(TN,23) F(TO,AO,24,1) S(TO,24) \
+ F(TP,AP,25,1) S(TP,25) F(TQ,AQ,26,1) S(TQ,26) F(TR,AR,27,1) S(TR,27)
+#endif
+#endif
+
+
+#define PROTOCCALLSFSUB1( UN,LN,T1) \
+ PROTOCCALLSFSUB14(UN,LN,T1,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFSUB2( UN,LN,T1,T2) \
+ PROTOCCALLSFSUB14(UN,LN,T1,T2,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFSUB3( UN,LN,T1,T2,T3) \
+ PROTOCCALLSFSUB14(UN,LN,T1,T2,T3,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFSUB4( UN,LN,T1,T2,T3,T4) \
+ PROTOCCALLSFSUB14(UN,LN,T1,T2,T3,T4,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFSUB5( UN,LN,T1,T2,T3,T4,T5) \
+ PROTOCCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFSUB6( UN,LN,T1,T2,T3,T4,T5,T6) \
+ PROTOCCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFSUB7( UN,LN,T1,T2,T3,T4,T5,T6,T7) \
+ PROTOCCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFSUB8( UN,LN,T1,T2,T3,T4,T5,T6,T7,T8) \
+ PROTOCCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFSUB9( UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9) \
+ PROTOCCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,CF_0,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFSUB10(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA) \
+ PROTOCCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFSUB11(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB) \
+ PROTOCCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFSUB12(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC) \
+ PROTOCCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,CF_0,CF_0)
+#define PROTOCCALLSFSUB13(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD) \
+ PROTOCCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,CF_0)
+
+
+#define PROTOCCALLSFSUB15(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF) \
+ PROTOCCALLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,CF_0,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFSUB16(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG) \
+ PROTOCCALLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFSUB17(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH) \
+ PROTOCCALLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFSUB18(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI) \
+ PROTOCCALLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,CF_0,CF_0)
+#define PROTOCCALLSFSUB19(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ) \
+ PROTOCCALLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,CF_0)
+
+#define PROTOCCALLSFSUB21(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL) \
+ PROTOCCALLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFSUB22(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM) \
+ PROTOCCALLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,CF_0,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFSUB23(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN) \
+ PROTOCCALLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFSUB24(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO) \
+ PROTOCCALLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFSUB25(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP) \
+ PROTOCCALLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,CF_0,CF_0)
+#define PROTOCCALLSFSUB26(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ) \
+ PROTOCCALLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,CF_0)
+
+
+#ifndef FCALLSC_QUALIFIER
+#ifdef VISUAL_CPLUSPLUS
+#define FCALLSC_QUALIFIER __stdcall
+#else
+#define FCALLSC_QUALIFIER
+#endif
+#endif
+
+#ifdef __cplusplus
+#define CFextern extern "C"
+#else
+#define CFextern extern
+#endif
+
+
+#ifdef CFSUBASFUN
+#define PROTOCCALLSFSUB0(UN,LN) \
+ PROTOCCALLSFFUN0( VOID,UN,LN)
+#define PROTOCCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
+ PROTOCCALLSFFUN14(VOID,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE)
+#define PROTOCCALLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK)\
+ PROTOCCALLSFFUN20(VOID,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK)
+#define PROTOCCALLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR)\
+ PROTOCCALLSFFUN27(VOID,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR)
+#else
+/* Note: Prevent compiler warnings, null #define PROTOCCALLSFSUB14/20 after
+ #include-ing cfortran.h if calling the FORTRAN wrapper within the same
+ source code where the wrapper is created. */
+#define PROTOCCALLSFSUB0(UN,LN) _(VOID,_cfPU)(CFC_(UN,LN))();
+#ifndef __CF__KnR
+#define PROTOCCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
+ _(VOID,_cfPU)(CFC_(UN,LN))( CFARGT14(NCF,KCF,_Z,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) );
+#define PROTOCCALLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK)\
+ _(VOID,_cfPU)(CFC_(UN,LN))( CFARGT20(NCF,KCF,_Z,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK) );
+#define PROTOCCALLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR)\
+ _(VOID,_cfPU)(CFC_(UN,LN))( CFARGT27(NCF,KCF,_Z,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR) );
+#else
+#define PROTOCCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
+ PROTOCCALLSFSUB0(UN,LN)
+#define PROTOCCALLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK) \
+ PROTOCCALLSFSUB0(UN,LN)
+#define PROTOCCALLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR) \
+ PROTOCCALLSFSUB0(UN,LN)
+#endif
+#endif
+
+
+#ifdef OLD_VAXC /* Allow %CC-I-PARAMNOTUSED. */
+#pragma standard
+#endif
+
+
+#define CCALLSFSUB1( UN,LN,T1, A1) \
+ CCALLSFSUB5 (UN,LN,T1,CF_0,CF_0,CF_0,CF_0,A1,0,0,0,0)
+#define CCALLSFSUB2( UN,LN,T1,T2, A1,A2) \
+ CCALLSFSUB5 (UN,LN,T1,T2,CF_0,CF_0,CF_0,A1,A2,0,0,0)
+#define CCALLSFSUB3( UN,LN,T1,T2,T3, A1,A2,A3) \
+ CCALLSFSUB5 (UN,LN,T1,T2,T3,CF_0,CF_0,A1,A2,A3,0,0)
+#define CCALLSFSUB4( UN,LN,T1,T2,T3,T4, A1,A2,A3,A4)\
+ CCALLSFSUB5 (UN,LN,T1,T2,T3,T4,CF_0,A1,A2,A3,A4,0)
+#define CCALLSFSUB5( UN,LN,T1,T2,T3,T4,T5, A1,A2,A3,A4,A5) \
+ CCALLSFSUB10(UN,LN,T1,T2,T3,T4,T5,CF_0,CF_0,CF_0,CF_0,CF_0,A1,A2,A3,A4,A5,0,0,0,0,0)
+#define CCALLSFSUB6( UN,LN,T1,T2,T3,T4,T5,T6, A1,A2,A3,A4,A5,A6) \
+ CCALLSFSUB10(UN,LN,T1,T2,T3,T4,T5,T6,CF_0,CF_0,CF_0,CF_0,A1,A2,A3,A4,A5,A6,0,0,0,0)
+#define CCALLSFSUB7( UN,LN,T1,T2,T3,T4,T5,T6,T7, A1,A2,A3,A4,A5,A6,A7) \
+ CCALLSFSUB10(UN,LN,T1,T2,T3,T4,T5,T6,T7,CF_0,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,0,0,0)
+#define CCALLSFSUB8( UN,LN,T1,T2,T3,T4,T5,T6,T7,T8, A1,A2,A3,A4,A5,A6,A7,A8) \
+ CCALLSFSUB10(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,0,0)
+#define CCALLSFSUB9( UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,A1,A2,A3,A4,A5,A6,A7,A8,A9)\
+ CCALLSFSUB10(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,0)
+#define CCALLSFSUB10(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA)\
+ CCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,CF_0,CF_0,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,0,0,0,0)
+#define CCALLSFSUB11(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB)\
+ CCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,CF_0,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,0,0,0)
+#define CCALLSFSUB12(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC)\
+ CCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,0,0)
+#define CCALLSFSUB13(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD)\
+ CCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,0)
+
+#ifdef __cplusplus
+#define CPPPROTOCLSFSUB0( UN,LN)
+#define CPPPROTOCLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE)
+#define CPPPROTOCLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK)
+#define CPPPROTOCLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR)
+#else
+#define CPPPROTOCLSFSUB0(UN,LN) \
+ PROTOCCALLSFSUB0(UN,LN)
+#define CPPPROTOCLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
+ PROTOCCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE)
+#define CPPPROTOCLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK) \
+ PROTOCCALLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK)
+#define CPPPROTOCLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR) \
+ PROTOCCALLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR)
+#endif
+
+#ifdef CFSUBASFUN
+#define CCALLSFSUB0(UN,LN) CCALLSFFUN0(UN,LN)
+#define CCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE)\
+ CCALLSFFUN14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE)
+#else
+/* do{...}while(0) allows if(a==b) FORT(); else BORT(); */
+#define CCALLSFSUB0( UN,LN) do{CPPPROTOCLSFSUB0(UN,LN) CFC_(UN,LN)();}while(0)
+#define CCALLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE)\
+do{VVCF(T1,A1,B1) VVCF(T2,A2,B2) VVCF(T3,A3,B3) VVCF(T4,A4,B4) VVCF(T5,A5,B5) \
+ VVCF(T6,A6,B6) VVCF(T7,A7,B7) VVCF(T8,A8,B8) VVCF(T9,A9,B9) VVCF(TA,AA,B10) \
+ VVCF(TB,AB,B11) VVCF(TC,AC,B12) VVCF(TD,AD,B13) VVCF(TE,AE,B14) \
+ CPPPROTOCLSFSUB14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
+ ACF(LN,T1,A1,1) ACF(LN,T2,A2,2) ACF(LN,T3,A3,3) \
+ ACF(LN,T4,A4,4) ACF(LN,T5,A5,5) ACF(LN,T6,A6,6) ACF(LN,T7,A7,7) \
+ ACF(LN,T8,A8,8) ACF(LN,T9,A9,9) ACF(LN,TA,AA,10) ACF(LN,TB,AB,11) \
+ ACF(LN,TC,AC,12) ACF(LN,TD,AD,13) ACF(LN,TE,AE,14) \
+ CFC_(UN,LN)( CFARGTA14(AACF,JCF,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE) );\
+ WCF(T1,A1,1) WCF(T2,A2,2) WCF(T3,A3,3) WCF(T4,A4,4) WCF(T5,A5,5) \
+ WCF(T6,A6,6) WCF(T7,A7,7) WCF(T8,A8,8) WCF(T9,A9,9) WCF(TA,AA,10) \
+ WCF(TB,AB,11) WCF(TC,AC,12) WCF(TD,AD,13) WCF(TE,AE,14) }while(0)
+#endif
+
+
+#if MAX_PREPRO_ARGS>31
+#define CCALLSFSUB15(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF)\
+ CCALLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,CF_0,CF_0,CF_0,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,0,0,0,0,0)
+#define CCALLSFSUB16(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG)\
+ CCALLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,CF_0,CF_0,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,0,0,0,0)
+#define CCALLSFSUB17(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH)\
+ CCALLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,CF_0,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,0,0,0)
+#define CCALLSFSUB18(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI)\
+ CCALLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,0,0)
+#define CCALLSFSUB19(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ)\
+ CCALLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,0)
+
+#ifdef CFSUBASFUN
+#define CCALLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH, \
+ TI,TJ,TK, A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK) \
+ CCALLSFFUN20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH, \
+ TI,TJ,TK, A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK)
+#else
+#define CCALLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH, \
+ TI,TJ,TK, A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK) \
+do{VVCF(T1,A1,B1) VVCF(T2,A2,B2) VVCF(T3,A3,B3) VVCF(T4,A4,B4) VVCF(T5,A5,B5) \
+ VVCF(T6,A6,B6) VVCF(T7,A7,B7) VVCF(T8,A8,B8) VVCF(T9,A9,B9) VVCF(TA,AA,B10) \
+ VVCF(TB,AB,B11) VVCF(TC,AC,B12) VVCF(TD,AD,B13) VVCF(TE,AE,B14) VVCF(TF,AF,B15) \
+ VVCF(TG,AG,B16) VVCF(TH,AH,B17) VVCF(TI,AI,B18) VVCF(TJ,AJ,B19) VVCF(TK,AK,B20) \
+ CPPPROTOCLSFSUB20(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK) \
+ ACF(LN,T1,A1,1) ACF(LN,T2,A2,2) ACF(LN,T3,A3,3) ACF(LN,T4,A4,4) \
+ ACF(LN,T5,A5,5) ACF(LN,T6,A6,6) ACF(LN,T7,A7,7) ACF(LN,T8,A8,8) \
+ ACF(LN,T9,A9,9) ACF(LN,TA,AA,10) ACF(LN,TB,AB,11) ACF(LN,TC,AC,12) \
+ ACF(LN,TD,AD,13) ACF(LN,TE,AE,14) ACF(LN,TF,AF,15) ACF(LN,TG,AG,16) \
+ ACF(LN,TH,AH,17) ACF(LN,TI,AI,18) ACF(LN,TJ,AJ,19) ACF(LN,TK,AK,20) \
+ CFC_(UN,LN)( CFARGTA20(AACF,JCF,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK) ); \
+ WCF(T1,A1,1) WCF(T2,A2,2) WCF(T3,A3,3) WCF(T4,A4,4) WCF(T5,A5,5) WCF(T6,A6,6) \
+ WCF(T7,A7,7) WCF(T8,A8,8) WCF(T9,A9,9) WCF(TA,AA,10) WCF(TB,AB,11) WCF(TC,AC,12) \
+ WCF(TD,AD,13) WCF(TE,AE,14) WCF(TF,AF,15) WCF(TG,AG,16) WCF(TH,AH,17) WCF(TI,AI,18) \
+ WCF(TJ,AJ,19) WCF(TK,AK,20) }while(0)
+#endif
+#endif /* MAX_PREPRO_ARGS */
+
+#if MAX_PREPRO_ARGS>31
+#define CCALLSFSUB21(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL)\
+ CCALLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,0,0,0,0,0,0)
+#define CCALLSFSUB22(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM)\
+ CCALLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,CF_0,CF_0,CF_0,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,0,0,0,0,0)
+#define CCALLSFSUB23(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN)\
+ CCALLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,CF_0,CF_0,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN,0,0,0,0)
+#define CCALLSFSUB24(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN,AO)\
+ CCALLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,CF_0,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN,AO,0,0,0)
+#define CCALLSFSUB25(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN,AO,AP)\
+ CCALLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN,AO,AP,0,0)
+#define CCALLSFSUB26(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN,AO,AP,AQ)\
+ CCALLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN,AO,AP,AQ,0)
+
+#ifdef CFSUBASFUN
+#define CCALLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR, \
+ A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN,AO,AP,AQ,AR) \
+ CCALLSFFUN27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR, \
+ A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN,AO,AP,AQ,AR)
+#else
+#define CCALLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR, \
+ A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN,AO,AP,AQ,AR) \
+do{VVCF(T1,A1,B1) VVCF(T2,A2,B2) VVCF(T3,A3,B3) VVCF(T4,A4,B4) VVCF(T5,A5,B5) \
+ VVCF(T6,A6,B6) VVCF(T7,A7,B7) VVCF(T8,A8,B8) VVCF(T9,A9,B9) VVCF(TA,AA,B10) \
+ VVCF(TB,AB,B11) VVCF(TC,AC,B12) VVCF(TD,AD,B13) VVCF(TE,AE,B14) VVCF(TF,AF,B15) \
+ VVCF(TG,AG,B16) VVCF(TH,AH,B17) VVCF(TI,AI,B18) VVCF(TJ,AJ,B19) VVCF(TK,AK,B20) \
+ VVCF(TL,AL,B21) VVCF(TM,AM,B22) VVCF(TN,AN,B23) VVCF(TO,AO,B24) VVCF(TP,AP,B25) \
+ VVCF(TQ,AQ,B26) VVCF(TR,AR,B27) \
+ CPPPROTOCLSFSUB27(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR) \
+ ACF(LN,T1,A1,1) ACF(LN,T2,A2,2) ACF(LN,T3,A3,3) ACF(LN,T4,A4,4) \
+ ACF(LN,T5,A5,5) ACF(LN,T6,A6,6) ACF(LN,T7,A7,7) ACF(LN,T8,A8,8) \
+ ACF(LN,T9,A9,9) ACF(LN,TA,AA,10) ACF(LN,TB,AB,11) ACF(LN,TC,AC,12) \
+ ACF(LN,TD,AD,13) ACF(LN,TE,AE,14) ACF(LN,TF,AF,15) ACF(LN,TG,AG,16) \
+ ACF(LN,TH,AH,17) ACF(LN,TI,AI,18) ACF(LN,TJ,AJ,19) ACF(LN,TK,AK,20) \
+ ACF(LN,TL,AL,21) ACF(LN,TM,AM,22) ACF(LN,TN,AN,23) ACF(LN,TO,AO,24) \
+ ACF(LN,TP,AP,25) ACF(LN,TQ,AQ,26) ACF(LN,TR,AR,27) \
+ CFC_(UN,LN)( CFARGTA27(AACF,JCF,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR,\
+ A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN,AO,AP,AQ,AR) ); \
+ WCF(T1,A1,1) WCF(T2,A2,2) WCF(T3,A3,3) WCF(T4,A4,4) WCF(T5,A5,5) WCF(T6,A6,6) \
+ WCF(T7,A7,7) WCF(T8,A8,8) WCF(T9,A9,9) WCF(TA,AA,10) WCF(TB,AB,11) WCF(TC,AC,12) \
+ WCF(TD,AD,13) WCF(TE,AE,14) WCF(TF,AF,15) WCF(TG,AG,16) WCF(TH,AH,17) WCF(TI,AI,18) \
+ WCF(TJ,AJ,19) WCF(TK,AK,20) WCF(TL,AL,21) WCF(TM,AM,22) WCF(TN,AN,23) WCF(TO,AO,24) \
+ WCF(TP,AP,25) WCF(TQ,AQ,26) WCF(TR,AR,27) }while(0)
+#endif
+#endif /* MAX_PREPRO_ARGS */
+
+/*-------------------------------------------------------------------------*/
+
+/* UTILITIES FOR C TO CALL FORTRAN FUNCTIONS */
+
+/*N.B. PROTOCCALLSFFUNn(..) generates code, whether or not the FORTRAN
+ function is called. Therefore, especially for creator's of C header files
+ for large FORTRAN libraries which include many functions, to reduce
+ compile time and object code size, it may be desirable to create
+ preprocessor directives to allow users to create code for only those
+ functions which they use. */
+
+/* The following defines the maximum length string that a function can return.
+ Of course it may be undefine-d and re-define-d before individual
+ PROTOCCALLSFFUNn(..) as required. It would also be nice to have this derived
+ from the individual machines' limits. */
+#define MAX_LEN_FORTRAN_FUNCTION_STRING 0x4FE
+
+/* The following defines a character used by CFORTRAN.H to flag the end of a
+ string coming out of a FORTRAN routine. */
+#define CFORTRAN_NON_CHAR 0x7F
+
+#ifdef OLD_VAXC /* Prevent %CC-I-PARAMNOTUSED. */
+#pragma nostandard
+#endif
+
+#define _SEP_(TN,C,cfCOMMA) _(__SEP_,C)(TN,cfCOMMA)
+#define __SEP_0(TN,cfCOMMA)
+#define __SEP_1(TN,cfCOMMA) _Icf(2,SEP,TN,cfCOMMA,0)
+#define INT_cfSEP(T,B) _(A,B)
+#define INTV_cfSEP(T,B) INT_cfSEP(T,B)
+#define INTVV_cfSEP(T,B) INT_cfSEP(T,B)
+#define INTVVV_cfSEP(T,B) INT_cfSEP(T,B)
+#define INTVVVV_cfSEP(T,B) INT_cfSEP(T,B)
+#define INTVVVVV_cfSEP(T,B) INT_cfSEP(T,B)
+#define INTVVVVVV_cfSEP(T,B) INT_cfSEP(T,B)
+#define INTVVVVVVV_cfSEP(T,B) INT_cfSEP(T,B)
+#define PINT_cfSEP(T,B) INT_cfSEP(T,B)
+#define PVOID_cfSEP(T,B) INT_cfSEP(T,B)
+#define ROUTINE_cfSEP(T,B) INT_cfSEP(T,B)
+#define SIMPLE_cfSEP(T,B) INT_cfSEP(T,B)
+#define VOID_cfSEP(T,B) INT_cfSEP(T,B) /* For FORTRAN calls C subr.s.*/
+#define STRING_cfSEP(T,B) INT_cfSEP(T,B)
+#define STRINGV_cfSEP(T,B) INT_cfSEP(T,B)
+#define PSTRING_cfSEP(T,B) INT_cfSEP(T,B)
+#define PSTRINGV_cfSEP(T,B) INT_cfSEP(T,B)
+#define PNSTRING_cfSEP(T,B) INT_cfSEP(T,B)
+#define PPSTRING_cfSEP(T,B) INT_cfSEP(T,B)
+#define ZTRINGV_cfSEP(T,B) INT_cfSEP(T,B)
+#define PZTRINGV_cfSEP(T,B) INT_cfSEP(T,B)
+
+#if defined(SIGNED_BYTE) || !defined(UNSIGNED_BYTE)
+#ifdef OLD_VAXC
+#define INTEGER_BYTE char /* Old VAXC barfs on 'signed char' */
+#else
+#define INTEGER_BYTE signed char /* default */
+#endif
+#else
+#define INTEGER_BYTE unsigned char
+#endif
+#define BYTEVVVVVVV_cfTYPE INTEGER_BYTE
+#define DOUBLEVVVVVVV_cfTYPE DOUBLE_PRECISION
+#define FLOATVVVVVVV_cfTYPE FORTRAN_REAL
+#define INTVVVVVVV_cfTYPE int
+#define LOGICALVVVVVVV_cfTYPE int
+#define LONGVVVVVVV_cfTYPE long
+#define SHORTVVVVVVV_cfTYPE short
+#define PBYTE_cfTYPE INTEGER_BYTE
+#define PDOUBLE_cfTYPE DOUBLE_PRECISION
+#define PFLOAT_cfTYPE FORTRAN_REAL
+#define PINT_cfTYPE int
+#define PLOGICAL_cfTYPE int
+#define PLONG_cfTYPE long
+#define PSHORT_cfTYPE short
+
+#define CFARGS0(A,T,V,W,X,Y,Z) _3(T,_cf,A)
+#define CFARGS1(A,T,V,W,X,Y,Z) _3(T,_cf,A)(V)
+#define CFARGS2(A,T,V,W,X,Y,Z) _3(T,_cf,A)(V,W)
+#define CFARGS3(A,T,V,W,X,Y,Z) _3(T,_cf,A)(V,W,X)
+#define CFARGS4(A,T,V,W,X,Y,Z) _3(T,_cf,A)(V,W,X,Y)
+#define CFARGS5(A,T,V,W,X,Y,Z) _3(T,_cf,A)(V,W,X,Y,Z)
+
+#define _Icf(N,T,I,X,Y) _(I,_cfINT)(N,T,I,X,Y,0)
+#define _Icf4(N,T,I,X,Y,Z) _(I,_cfINT)(N,T,I,X,Y,Z)
+#define BYTE_cfINT(N,A,B,X,Y,Z) DOUBLE_cfINT(N,A,B,X,Y,Z)
+#define DOUBLE_cfINT(N,A,B,X,Y,Z) _(CFARGS,N)(A,INT,B,X,Y,Z,0)
+#define FLOAT_cfINT(N,A,B,X,Y,Z) DOUBLE_cfINT(N,A,B,X,Y,Z)
+#define INT_cfINT(N,A,B,X,Y,Z) DOUBLE_cfINT(N,A,B,X,Y,Z)
+#define LOGICAL_cfINT(N,A,B,X,Y,Z) DOUBLE_cfINT(N,A,B,X,Y,Z)
+#define LONG_cfINT(N,A,B,X,Y,Z) DOUBLE_cfINT(N,A,B,X,Y,Z)
+#define SHORT_cfINT(N,A,B,X,Y,Z) DOUBLE_cfINT(N,A,B,X,Y,Z)
+#define PBYTE_cfINT(N,A,B,X,Y,Z) PDOUBLE_cfINT(N,A,B,X,Y,Z)
+#define PDOUBLE_cfINT(N,A,B,X,Y,Z) _(CFARGS,N)(A,PINT,B,X,Y,Z,0)
+#define PFLOAT_cfINT(N,A,B,X,Y,Z) PDOUBLE_cfINT(N,A,B,X,Y,Z)
+#define PINT_cfINT(N,A,B,X,Y,Z) PDOUBLE_cfINT(N,A,B,X,Y,Z)
+#define PLOGICAL_cfINT(N,A,B,X,Y,Z) PDOUBLE_cfINT(N,A,B,X,Y,Z)
+#define PLONG_cfINT(N,A,B,X,Y,Z) PDOUBLE_cfINT(N,A,B,X,Y,Z)
+#define PSHORT_cfINT(N,A,B,X,Y,Z) PDOUBLE_cfINT(N,A,B,X,Y,Z)
+#define BYTEV_cfINT(N,A,B,X,Y,Z) DOUBLEV_cfINT(N,A,B,X,Y,Z)
+#define BYTEVV_cfINT(N,A,B,X,Y,Z) DOUBLEVV_cfINT(N,A,B,X,Y,Z)
+#define BYTEVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVV_cfINT(N,A,B,X,Y,Z)
+#define BYTEVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVV_cfINT(N,A,B,X,Y,Z)
+#define BYTEVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVV_cfINT(N,A,B,X,Y,Z)
+#define BYTEVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVV_cfINT(N,A,B,X,Y,Z)
+#define BYTEVVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVVV_cfINT(N,A,B,X,Y,Z)
+#define DOUBLEV_cfINT(N,A,B,X,Y,Z) _(CFARGS,N)(A,INTV,B,X,Y,Z,0)
+#define DOUBLEVV_cfINT(N,A,B,X,Y,Z) _(CFARGS,N)(A,INTVV,B,X,Y,Z,0)
+#define DOUBLEVVV_cfINT(N,A,B,X,Y,Z) _(CFARGS,N)(A,INTVVV,B,X,Y,Z,0)
+#define DOUBLEVVVV_cfINT(N,A,B,X,Y,Z) _(CFARGS,N)(A,INTVVVV,B,X,Y,Z,0)
+#define DOUBLEVVVVV_cfINT(N,A,B,X,Y,Z) _(CFARGS,N)(A,INTVVVVV,B,X,Y,Z,0)
+#define DOUBLEVVVVVV_cfINT(N,A,B,X,Y,Z) _(CFARGS,N)(A,INTVVVVVV,B,X,Y,Z,0)
+#define DOUBLEVVVVVVV_cfINT(N,A,B,X,Y,Z) _(CFARGS,N)(A,INTVVVVVVV,B,X,Y,Z,0)
+#define FLOATV_cfINT(N,A,B,X,Y,Z) DOUBLEV_cfINT(N,A,B,X,Y,Z)
+#define FLOATVV_cfINT(N,A,B,X,Y,Z) DOUBLEVV_cfINT(N,A,B,X,Y,Z)
+#define FLOATVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVV_cfINT(N,A,B,X,Y,Z)
+#define FLOATVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVV_cfINT(N,A,B,X,Y,Z)
+#define FLOATVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVV_cfINT(N,A,B,X,Y,Z)
+#define FLOATVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVV_cfINT(N,A,B,X,Y,Z)
+#define FLOATVVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVVV_cfINT(N,A,B,X,Y,Z)
+#define INTV_cfINT(N,A,B,X,Y,Z) DOUBLEV_cfINT(N,A,B,X,Y,Z)
+#define INTVV_cfINT(N,A,B,X,Y,Z) DOUBLEVV_cfINT(N,A,B,X,Y,Z)
+#define INTVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVV_cfINT(N,A,B,X,Y,Z)
+#define INTVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVV_cfINT(N,A,B,X,Y,Z)
+#define INTVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVV_cfINT(N,A,B,X,Y,Z)
+#define INTVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVV_cfINT(N,A,B,X,Y,Z)
+#define INTVVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVVV_cfINT(N,A,B,X,Y,Z)
+#define LOGICALV_cfINT(N,A,B,X,Y,Z) DOUBLEV_cfINT(N,A,B,X,Y,Z)
+#define LOGICALVV_cfINT(N,A,B,X,Y,Z) DOUBLEVV_cfINT(N,A,B,X,Y,Z)
+#define LOGICALVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVV_cfINT(N,A,B,X,Y,Z)
+#define LOGICALVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVV_cfINT(N,A,B,X,Y,Z)
+#define LOGICALVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVV_cfINT(N,A,B,X,Y,Z)
+#define LOGICALVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVV_cfINT(N,A,B,X,Y,Z)
+#define LOGICALVVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVVV_cfINT(N,A,B,X,Y,Z)
+#define LONGV_cfINT(N,A,B,X,Y,Z) DOUBLEV_cfINT(N,A,B,X,Y,Z)
+#define LONGVV_cfINT(N,A,B,X,Y,Z) DOUBLEVV_cfINT(N,A,B,X,Y,Z)
+#define LONGVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVV_cfINT(N,A,B,X,Y,Z)
+#define LONGVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVV_cfINT(N,A,B,X,Y,Z)
+#define LONGVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVV_cfINT(N,A,B,X,Y,Z)
+#define LONGVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVV_cfINT(N,A,B,X,Y,Z)
+#define LONGVVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVVV_cfINT(N,A,B,X,Y,Z)
+#define SHORTV_cfINT(N,A,B,X,Y,Z) DOUBLEV_cfINT(N,A,B,X,Y,Z)
+#define SHORTVV_cfINT(N,A,B,X,Y,Z) DOUBLEVV_cfINT(N,A,B,X,Y,Z)
+#define SHORTVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVV_cfINT(N,A,B,X,Y,Z)
+#define SHORTVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVV_cfINT(N,A,B,X,Y,Z)
+#define SHORTVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVV_cfINT(N,A,B,X,Y,Z)
+#define SHORTVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVV_cfINT(N,A,B,X,Y,Z)
+#define SHORTVVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVVV_cfINT(N,A,B,X,Y,Z)
+#define PVOID_cfINT(N,A,B,X,Y,Z) _(CFARGS,N)(A,B,B,X,Y,Z,0)
+#define ROUTINE_cfINT(N,A,B,X,Y,Z) PVOID_cfINT(N,A,B,X,Y,Z)
+/*CRAY coughs on the first,
+ i.e. the usual trouble of not being able to
+ define macros to macros with arguments.
+ New ultrix is worse, it coughs on all such uses.
+ */
+/*#define SIMPLE_cfINT PVOID_cfINT*/
+#define SIMPLE_cfINT(N,A,B,X,Y,Z) PVOID_cfINT(N,A,B,X,Y,Z)
+#define VOID_cfINT(N,A,B,X,Y,Z) PVOID_cfINT(N,A,B,X,Y,Z)
+#define STRING_cfINT(N,A,B,X,Y,Z) PVOID_cfINT(N,A,B,X,Y,Z)
+#define STRINGV_cfINT(N,A,B,X,Y,Z) PVOID_cfINT(N,A,B,X,Y,Z)
+#define PSTRING_cfINT(N,A,B,X,Y,Z) PVOID_cfINT(N,A,B,X,Y,Z)
+#define PSTRINGV_cfINT(N,A,B,X,Y,Z) PVOID_cfINT(N,A,B,X,Y,Z)
+#define PNSTRING_cfINT(N,A,B,X,Y,Z) PVOID_cfINT(N,A,B,X,Y,Z)
+#define PPSTRING_cfINT(N,A,B,X,Y,Z) PVOID_cfINT(N,A,B,X,Y,Z)
+#define ZTRINGV_cfINT(N,A,B,X,Y,Z) PVOID_cfINT(N,A,B,X,Y,Z)
+#define PZTRINGV_cfINT(N,A,B,X,Y,Z) PVOID_cfINT(N,A,B,X,Y,Z)
+#define CF_0_cfINT(N,A,B,X,Y,Z)
+
+
+#define UCF(TN,I,C) _SEP_(TN,C,cfCOMMA) _Icf(2,U,TN,_(A,I),0)
+#define UUCF(TN,I,C) _SEP_(TN,C,cfCOMMA) _SEP_(TN,1,I)
+#define UUUCF(TN,I,C) _SEP_(TN,C,cfCOLON) _Icf(2,U,TN,_(A,I),0)
+#define INT_cfU(T,A) _(T,VVVVVVV_cfTYPE) A
+#define INTV_cfU(T,A) _(T,VVVVVV_cfTYPE) * A
+#define INTVV_cfU(T,A) _(T,VVVVV_cfTYPE) * A
+#define INTVVV_cfU(T,A) _(T,VVVV_cfTYPE) * A
+#define INTVVVV_cfU(T,A) _(T,VVV_cfTYPE) * A
+#define INTVVVVV_cfU(T,A) _(T,VV_cfTYPE) * A
+#define INTVVVVVV_cfU(T,A) _(T,V_cfTYPE) * A
+#define INTVVVVVVV_cfU(T,A) _(T,_cfTYPE) * A
+#define PINT_cfU(T,A) _(T,_cfTYPE) * A
+#define PVOID_cfU(T,A) void *A
+#define ROUTINE_cfU(T,A) void (*A)(CF_NULL_PROTO)
+#define VOID_cfU(T,A) void A /* Needed for C calls FORTRAN sub.s. */
+#define STRING_cfU(T,A) char *A /* via VOID and wrapper. */
+#define STRINGV_cfU(T,A) char *A
+#define PSTRING_cfU(T,A) char *A
+#define PSTRINGV_cfU(T,A) char *A
+#define ZTRINGV_cfU(T,A) char *A
+#define PZTRINGV_cfU(T,A) char *A
+
+/* VOID breaks U into U and UU. */
+#define INT_cfUU(T,A) _(T,VVVVVVV_cfTYPE) A
+#define VOID_cfUU(T,A) /* Needed for FORTRAN calls C sub.s. */
+#define STRING_cfUU(T,A) char *A
+
+
+#define BYTE_cfPU(A) CFextern INTEGER_BYTE FCALLSC_QUALIFIER A
+#define DOUBLE_cfPU(A) CFextern DOUBLE_PRECISION FCALLSC_QUALIFIER A
+#if ! (defined(FLOATFUNCTIONTYPE)&&defined(ASSIGNFLOAT)&&defined(RETURNFLOAT))
+#define FLOAT_cfPU(A) CFextern FORTRAN_REAL FCALLSC_QUALIFIER A
+#else
+#define FLOAT_cfPU(A) CFextern FLOATFUNCTIONTYPE FCALLSC_QUALIFIER A
+#endif
+#define INT_cfPU(A) CFextern int FCALLSC_QUALIFIER A
+#define LOGICAL_cfPU(A) CFextern int FCALLSC_QUALIFIER A
+#define LONG_cfPU(A) CFextern long FCALLSC_QUALIFIER A
+#define SHORT_cfPU(A) CFextern short FCALLSC_QUALIFIER A
+#define STRING_cfPU(A) CFextern void FCALLSC_QUALIFIER A
+#define VOID_cfPU(A) CFextern void FCALLSC_QUALIFIER A
+
+#define BYTE_cfE INTEGER_BYTE A0;
+#define DOUBLE_cfE DOUBLE_PRECISION A0;
+#if ! (defined(FLOATFUNCTIONTYPE)&&defined(ASSIGNFLOAT)&&defined(RETURNFLOAT))
+#define FLOAT_cfE FORTRAN_REAL A0;
+#else
+#define FLOAT_cfE FORTRAN_REAL AA0; FLOATFUNCTIONTYPE A0;
+#endif
+#define INT_cfE int A0;
+#define LOGICAL_cfE int A0;
+#define LONG_cfE long A0;
+#define SHORT_cfE short A0;
+#define VOID_cfE
+#ifdef vmsFortran
+#define STRING_cfE static char AA0[1+MAX_LEN_FORTRAN_FUNCTION_STRING]; \
+ static fstring A0 = \
+ {MAX_LEN_FORTRAN_FUNCTION_STRING,DSC$K_DTYPE_T,DSC$K_CLASS_S,AA0};\
+ memset(AA0, CFORTRAN_NON_CHAR, MAX_LEN_FORTRAN_FUNCTION_STRING);\
+ *(AA0+MAX_LEN_FORTRAN_FUNCTION_STRING)='\0';
+#else
+#ifdef CRAYFortran
+#define STRING_cfE static char AA0[1+MAX_LEN_FORTRAN_FUNCTION_STRING]; \
+ static _fcd A0; *(AA0+MAX_LEN_FORTRAN_FUNCTION_STRING)='\0';\
+ memset(AA0,CFORTRAN_NON_CHAR, MAX_LEN_FORTRAN_FUNCTION_STRING);\
+ A0 = _cptofcd(AA0,MAX_LEN_FORTRAN_FUNCTION_STRING);
+#else
+/* 'cc: SC3.0.1 13 Jul 1994' barfs on char A0[0x4FE+1];
+ * char A0[0x4FE +1]; char A0[1+0x4FE]; are both OK. */
+#define STRING_cfE static char A0[1+MAX_LEN_FORTRAN_FUNCTION_STRING]; \
+ memset(A0, CFORTRAN_NON_CHAR, \
+ MAX_LEN_FORTRAN_FUNCTION_STRING); \
+ *(A0+MAX_LEN_FORTRAN_FUNCTION_STRING)='\0';
+#endif
+#endif
+/* ESTRING must use static char. array which is guaranteed to exist after
+ function returns. */
+
+/* N.B.i) The diff. for 0 (Zero) and >=1 arguments.
+ ii)That the following create an unmatched bracket, i.e. '(', which
+ must of course be matched in the call.
+ iii)Commas must be handled very carefully */
+#define INT_cfGZ(T,UN,LN) A0=CFC_(UN,LN)(
+#define VOID_cfGZ(T,UN,LN) CFC_(UN,LN)(
+#ifdef vmsFortran
+#define STRING_cfGZ(T,UN,LN) CFC_(UN,LN)(&A0
+#else
+#if defined(CRAYFortran) || defined(AbsoftUNIXFortran) || defined(AbsoftProFortran)
+#define STRING_cfGZ(T,UN,LN) CFC_(UN,LN)( A0
+#else
+#define STRING_cfGZ(T,UN,LN) CFC_(UN,LN)( A0,MAX_LEN_FORTRAN_FUNCTION_STRING
+#endif
+#endif
+
+#define INT_cfG(T,UN,LN) INT_cfGZ(T,UN,LN)
+#define VOID_cfG(T,UN,LN) VOID_cfGZ(T,UN,LN)
+#define STRING_cfG(T,UN,LN) STRING_cfGZ(T,UN,LN), /*, is only diff. from _cfG*/
+
+#define BYTEVVVVVVV_cfPP
+#define INTVVVVVVV_cfPP /* These complement FLOATVVVVVVV_cfPP. */
+#define DOUBLEVVVVVVV_cfPP
+#define LOGICALVVVVVVV_cfPP
+#define LONGVVVVVVV_cfPP
+#define SHORTVVVVVVV_cfPP
+#define PBYTE_cfPP
+#define PINT_cfPP
+#define PDOUBLE_cfPP
+#define PLOGICAL_cfPP
+#define PLONG_cfPP
+#define PSHORT_cfPP
+#define PFLOAT_cfPP FLOATVVVVVVV_cfPP
+
+#define BCF(TN,AN,C) _SEP_(TN,C,cfCOMMA) _Icf(2,B,TN,AN,0)
+#define INT_cfB(T,A) (_(T,VVVVVVV_cfTYPE)) A
+#define INTV_cfB(T,A) A
+#define INTVV_cfB(T,A) (A)[0]
+#define INTVVV_cfB(T,A) (A)[0][0]
+#define INTVVVV_cfB(T,A) (A)[0][0][0]
+#define INTVVVVV_cfB(T,A) (A)[0][0][0][0]
+#define INTVVVVVV_cfB(T,A) (A)[0][0][0][0][0]
+#define INTVVVVVVV_cfB(T,A) (A)[0][0][0][0][0][0]
+#define PINT_cfB(T,A) _(T,_cfPP)&A
+#define STRING_cfB(T,A) (char *) A
+#define STRINGV_cfB(T,A) (char *) A
+#define PSTRING_cfB(T,A) (char *) A
+#define PSTRINGV_cfB(T,A) (char *) A
+#define PVOID_cfB(T,A) (void *) A
+#define ROUTINE_cfB(T,A) (cfCAST_FUNCTION)A
+#define ZTRINGV_cfB(T,A) (char *) A
+#define PZTRINGV_cfB(T,A) (char *) A
+
+#define SCF(TN,NAME,I,A) _(TN,_cfSTR)(3,S,NAME,I,A,0,0)
+#define DEFAULT_cfS(M,I,A)
+#define LOGICAL_cfS(M,I,A)
+#define PLOGICAL_cfS(M,I,A)
+#define STRING_cfS(M,I,A) ,sizeof(A)
+#define STRINGV_cfS(M,I,A) ,( (unsigned)0xFFFF*firstindexlength(A) \
+ +secondindexlength(A))
+#define PSTRING_cfS(M,I,A) ,sizeof(A)
+#define PSTRINGV_cfS(M,I,A) STRINGV_cfS(M,I,A)
+#define ZTRINGV_cfS(M,I,A)
+#define PZTRINGV_cfS(M,I,A)
+
+#define HCF(TN,I) _(TN,_cfSTR)(3,H,cfCOMMA, H,_(C,I),0,0)
+#define HHCF(TN,I) _(TN,_cfSTR)(3,H,cfCOMMA,HH,_(C,I),0,0)
+#define HHHCF(TN,I) _(TN,_cfSTR)(3,H,cfCOLON, H,_(C,I),0,0)
+#define H_CF_SPECIAL unsigned
+#define HH_CF_SPECIAL
+#define DEFAULT_cfH(M,I,A)
+#define LOGICAL_cfH(S,U,B)
+#define PLOGICAL_cfH(S,U,B)
+#define STRING_cfH(S,U,B) _(A,S) _(U,_CF_SPECIAL) B
+#define STRINGV_cfH(S,U,B) STRING_cfH(S,U,B)
+#define PSTRING_cfH(S,U,B) STRING_cfH(S,U,B)
+#define PSTRINGV_cfH(S,U,B) STRING_cfH(S,U,B)
+#define PNSTRING_cfH(S,U,B) STRING_cfH(S,U,B)
+#define PPSTRING_cfH(S,U,B) STRING_cfH(S,U,B)
+#define ZTRINGV_cfH(S,U,B)
+#define PZTRINGV_cfH(S,U,B)
+
+/* Need VOID_cfSTR because Absoft forced function types go through _cfSTR. */
+/* No spaces inside expansion. They screws up macro catenation kludge. */
+#define VOID_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define BYTE_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define DOUBLE_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define FLOAT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define INT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define LOGICAL_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,LOGICAL,A,B,C,D,E)
+#define LONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define SHORT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define BYTEV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define BYTEVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define BYTEVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define BYTEVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define BYTEVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define BYTEVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define BYTEVVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define DOUBLEV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define DOUBLEVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define DOUBLEVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define DOUBLEVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define DOUBLEVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define DOUBLEVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define DOUBLEVVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define FLOATV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define FLOATVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define FLOATVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define FLOATVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define FLOATVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define FLOATVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define FLOATVVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define INTV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define INTVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define INTVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define INTVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define INTVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define INTVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define INTVVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define LOGICALV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define LOGICALVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define LOGICALVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define LOGICALVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define LOGICALVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define LOGICALVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define LOGICALVVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define LONGV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define LONGVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define LONGVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define LONGVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define LONGVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define LONGVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define LONGVVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define SHORTV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define SHORTVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define SHORTVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define SHORTVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define SHORTVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define SHORTVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define SHORTVVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define PBYTE_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define PDOUBLE_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define PFLOAT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define PINT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define PLOGICAL_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,PLOGICAL,A,B,C,D,E)
+#define PLONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define PSHORT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define STRING_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,STRING,A,B,C,D,E)
+#define PSTRING_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,PSTRING,A,B,C,D,E)
+#define STRINGV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,STRINGV,A,B,C,D,E)
+#define PSTRINGV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,PSTRINGV,A,B,C,D,E)
+#define PNSTRING_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,PNSTRING,A,B,C,D,E)
+#define PPSTRING_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,PPSTRING,A,B,C,D,E)
+#define PVOID_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define ROUTINE_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define SIMPLE_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define ZTRINGV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,ZTRINGV,A,B,C,D,E)
+#define PZTRINGV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,PZTRINGV,A,B,C,D,E)
+#define CF_0_cfSTR(N,T,A,B,C,D,E)
+
+/* See ACF table comments, which explain why CCF was split into two. */
+#define CCF(NAME,TN,I) _(TN,_cfSTR)(5,C,NAME,I,_(A,I),_(B,I),_(C,I))
+#define DEFAULT_cfC(M,I,A,B,C)
+#define LOGICAL_cfC(M,I,A,B,C) A=C2FLOGICAL( A);
+#define PLOGICAL_cfC(M,I,A,B,C) *A=C2FLOGICAL(*A);
+#ifdef vmsFortran
+#define STRING_cfC(M,I,A,B,C) (B.clen=strlen(A),B.f.dsc$a_pointer=A, \
+ C==sizeof(char*)||C==(unsigned)(B.clen+1)?B.f.dsc$w_length=B.clen: \
+ (memset((A)+B.clen,' ',C-B.clen-1),A[B.f.dsc$w_length=C-1]='\0'));
+ /* PSTRING_cfC to beware of array A which does not contain any \0. */
+#define PSTRING_cfC(M,I,A,B,C) (B.dsc$a_pointer=A, C==sizeof(char*) ? \
+ B.dsc$w_length=strlen(A): (A[C-1]='\0',B.dsc$w_length=strlen(A), \
+ memset((A)+B.dsc$w_length,' ',C-B.dsc$w_length-1), B.dsc$w_length=C-1));
+#else
+#define STRING_cfC(M,I,A,B,C) (B.clen=strlen(A), \
+ C==sizeof(char*)||C==(unsigned)(B.clen+1)?B.flen=B.clen: \
+ (memset((A)+B.clen,' ',C-B.clen-1),A[B.flen=C-1]='\0'));
+#define PSTRING_cfC(M,I,A,B,C) (C==sizeof(char*)? B=strlen(A): \
+ (A[C-1]='\0',B=strlen(A),memset((A)+B,' ',C-B-1),B=C-1));
+#endif
+ /* For CRAYFortran for (P)STRINGV_cfC, B.fs is set, but irrelevant. */
+#define STRINGV_cfC(M,I,A,B,C) \
+ AATRINGV_cfA( A,B,(C/0xFFFF)*(C%0xFFFF),C/0xFFFF,C%0xFFFF)
+#define PSTRINGV_cfC(M,I,A,B,C) \
+ APATRINGV_cfA( A,B,(C/0xFFFF)*(C%0xFFFF),C/0xFFFF,C%0xFFFF)
+#define ZTRINGV_cfC(M,I,A,B,C) \
+ AATRINGV_cfA( A,B, (_3(M,_ELEMS_,I))*((_3(M,_ELEMLEN_,I))+1), \
+ (_3(M,_ELEMS_,I)), (_3(M,_ELEMLEN_,I))+1 )
+#define PZTRINGV_cfC(M,I,A,B,C) \
+ APATRINGV_cfA( A,B, (_3(M,_ELEMS_,I))*((_3(M,_ELEMLEN_,I))+1), \
+ (_3(M,_ELEMS_,I)), (_3(M,_ELEMLEN_,I))+1 )
+
+#define BYTE_cfCCC(A,B) &A
+#define DOUBLE_cfCCC(A,B) &A
+#if !defined(__CF__KnR)
+#define FLOAT_cfCCC(A,B) &A
+ /* Although the VAX doesn't, at least the */
+#else /* HP and K&R mips promote float arg.'s of */
+#define FLOAT_cfCCC(A,B) &B /* unprototyped functions to double. Cannot */
+#endif /* use A here to pass the argument to FORTRAN. */
+#define INT_cfCCC(A,B) &A
+#define LOGICAL_cfCCC(A,B) &A
+#define LONG_cfCCC(A,B) &A
+#define SHORT_cfCCC(A,B) &A
+#define PBYTE_cfCCC(A,B) A
+#define PDOUBLE_cfCCC(A,B) A
+#define PFLOAT_cfCCC(A,B) A
+#define PINT_cfCCC(A,B) A
+#define PLOGICAL_cfCCC(A,B) B=A /* B used to keep a common W table. */
+#define PLONG_cfCCC(A,B) A
+#define PSHORT_cfCCC(A,B) A
+
+#define CCCF(TN,I,M) _SEP_(TN,M,cfCOMMA) _Icf(3,CC,TN,_(A,I),_(B,I))
+#define INT_cfCC(T,A,B) _(T,_cfCCC)(A,B)
+#define INTV_cfCC(T,A,B) A
+#define INTVV_cfCC(T,A,B) A
+#define INTVVV_cfCC(T,A,B) A
+#define INTVVVV_cfCC(T,A,B) A
+#define INTVVVVV_cfCC(T,A,B) A
+#define INTVVVVVV_cfCC(T,A,B) A
+#define INTVVVVVVV_cfCC(T,A,B) A
+#define PINT_cfCC(T,A,B) _(T,_cfCCC)(A,B)
+#define PVOID_cfCC(T,A,B) A
+#if defined(apolloFortran) || defined(hpuxFortran800) || defined(AbsoftUNIXFortran)
+#define ROUTINE_cfCC(T,A,B) &A
+#else
+#define ROUTINE_cfCC(T,A,B) A
+#endif
+#define SIMPLE_cfCC(T,A,B) A
+#ifdef vmsFortran
+#define STRING_cfCC(T,A,B) &B.f
+#define STRINGV_cfCC(T,A,B) &B
+#define PSTRING_cfCC(T,A,B) &B
+#define PSTRINGV_cfCC(T,A,B) &B
+#else
+#ifdef CRAYFortran
+#define STRING_cfCC(T,A,B) _cptofcd(A,B.flen)
+#define STRINGV_cfCC(T,A,B) _cptofcd(B.s,B.flen)
+#define PSTRING_cfCC(T,A,B) _cptofcd(A,B)
+#define PSTRINGV_cfCC(T,A,B) _cptofcd(A,B.flen)
+#else
+#define STRING_cfCC(T,A,B) A
+#define STRINGV_cfCC(T,A,B) B.fs
+#define PSTRING_cfCC(T,A,B) A
+#define PSTRINGV_cfCC(T,A,B) B.fs
+#endif
+#endif
+#define ZTRINGV_cfCC(T,A,B) STRINGV_cfCC(T,A,B)
+#define PZTRINGV_cfCC(T,A,B) PSTRINGV_cfCC(T,A,B)
+
+#define BYTE_cfX return A0;
+#define DOUBLE_cfX return A0;
+#if ! (defined(FLOATFUNCTIONTYPE)&&defined(ASSIGNFLOAT)&&defined(RETURNFLOAT))
+#define FLOAT_cfX return A0;
+#else
+#define FLOAT_cfX ASSIGNFLOAT(AA0,A0); return AA0;
+#endif
+#define INT_cfX return A0;
+#define LOGICAL_cfX return F2CLOGICAL(A0);
+#define LONG_cfX return A0;
+#define SHORT_cfX return A0;
+#define VOID_cfX return ;
+#if defined(vmsFortran) || defined(CRAYFortran)
+#define STRING_cfX return kill_trailing( \
+ kill_trailing(AA0,CFORTRAN_NON_CHAR),' ');
+#else
+#define STRING_cfX return kill_trailing( \
+ kill_trailing( A0,CFORTRAN_NON_CHAR),' ');
+#endif
+
+#define CFFUN(NAME) _(__cf__,NAME)
+
+/* Note that we don't use LN here, but we keep it for consistency. */
+#define CCALLSFFUN0(UN,LN) CFFUN(UN)()
+
+#ifdef OLD_VAXC /* Allow %CC-I-PARAMNOTUSED. */
+#pragma standard
+#endif
+
+#define CCALLSFFUN1( UN,LN,T1, A1) \
+ CCALLSFFUN5 (UN,LN,T1,CF_0,CF_0,CF_0,CF_0,A1,0,0,0,0)
+#define CCALLSFFUN2( UN,LN,T1,T2, A1,A2) \
+ CCALLSFFUN5 (UN,LN,T1,T2,CF_0,CF_0,CF_0,A1,A2,0,0,0)
+#define CCALLSFFUN3( UN,LN,T1,T2,T3, A1,A2,A3) \
+ CCALLSFFUN5 (UN,LN,T1,T2,T3,CF_0,CF_0,A1,A2,A3,0,0)
+#define CCALLSFFUN4( UN,LN,T1,T2,T3,T4, A1,A2,A3,A4)\
+ CCALLSFFUN5 (UN,LN,T1,T2,T3,T4,CF_0,A1,A2,A3,A4,0)
+#define CCALLSFFUN5( UN,LN,T1,T2,T3,T4,T5, A1,A2,A3,A4,A5) \
+ CCALLSFFUN10(UN,LN,T1,T2,T3,T4,T5,CF_0,CF_0,CF_0,CF_0,CF_0,A1,A2,A3,A4,A5,0,0,0,0,0)
+#define CCALLSFFUN6( UN,LN,T1,T2,T3,T4,T5,T6, A1,A2,A3,A4,A5,A6) \
+ CCALLSFFUN10(UN,LN,T1,T2,T3,T4,T5,T6,CF_0,CF_0,CF_0,CF_0,A1,A2,A3,A4,A5,A6,0,0,0,0)
+#define CCALLSFFUN7( UN,LN,T1,T2,T3,T4,T5,T6,T7, A1,A2,A3,A4,A5,A6,A7) \
+ CCALLSFFUN10(UN,LN,T1,T2,T3,T4,T5,T6,T7,CF_0,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,0,0,0)
+#define CCALLSFFUN8( UN,LN,T1,T2,T3,T4,T5,T6,T7,T8, A1,A2,A3,A4,A5,A6,A7,A8) \
+ CCALLSFFUN10(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,0,0)
+#define CCALLSFFUN9( UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,A1,A2,A3,A4,A5,A6,A7,A8,A9)\
+ CCALLSFFUN10(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,0)
+#define CCALLSFFUN10(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA)\
+ CCALLSFFUN14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,CF_0,CF_0,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,0,0,0,0)
+#define CCALLSFFUN11(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB)\
+ CCALLSFFUN14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,CF_0,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,0,0,0)
+#define CCALLSFFUN12(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC)\
+ CCALLSFFUN14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,CF_0,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,0,0)
+#define CCALLSFFUN13(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD)\
+ CCALLSFFUN14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,CF_0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,0)
+
+#define CCALLSFFUN14(UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE)\
+((CFFUN(UN)( BCF(T1,A1,0) BCF(T2,A2,1) BCF(T3,A3,1) BCF(T4,A4,1) BCF(T5,A5,1) \
+ BCF(T6,A6,1) BCF(T7,A7,1) BCF(T8,A8,1) BCF(T9,A9,1) BCF(TA,AA,1) \
+ BCF(TB,AB,1) BCF(TC,AC,1) BCF(TD,AD,1) BCF(TE,AE,1) \
+ SCF(T1,LN,1,A1) SCF(T2,LN,2,A2) SCF(T3,LN,3,A3) SCF(T4,LN,4,A4) \
+ SCF(T5,LN,5,A5) SCF(T6,LN,6,A6) SCF(T7,LN,7,A7) SCF(T8,LN,8,A8) \
+ SCF(T9,LN,9,A9) SCF(TA,LN,10,AA) SCF(TB,LN,11,AB) SCF(TC,LN,12,AC) \
+ SCF(TD,LN,13,AD) SCF(TE,LN,14,AE))))
+
+/* N.B. Create a separate function instead of using (call function, function
+value here) because in order to create the variables needed for the input
+arg.'s which may be const.'s one has to do the creation within {}, but these
+can never be placed within ()'s. Therefore one must create wrapper functions.
+gcc, on the other hand may be able to avoid the wrapper functions. */
+
+/* Prototypes are needed to correctly handle the value returned correctly. N.B.
+Can only have prototype arg.'s with difficulty, a la G... table since FORTRAN
+functions returning strings have extra arg.'s. Don't bother, since this only
+causes a compiler warning to come up when one uses FCALLSCFUNn and CCALLSFFUNn
+for the same function in the same source code. Something done by the experts in
+debugging only.*/
+
+#define PROTOCCALLSFFUN0(F,UN,LN) \
+_(F,_cfPU)( CFC_(UN,LN))(CF_NULL_PROTO); \
+static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(F,_cfX)}
+
+#define PROTOCCALLSFFUN1( T0,UN,LN,T1) \
+ PROTOCCALLSFFUN5 (T0,UN,LN,T1,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFFUN2( T0,UN,LN,T1,T2) \
+ PROTOCCALLSFFUN5 (T0,UN,LN,T1,T2,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFFUN3( T0,UN,LN,T1,T2,T3) \
+ PROTOCCALLSFFUN5 (T0,UN,LN,T1,T2,T3,CF_0,CF_0)
+#define PROTOCCALLSFFUN4( T0,UN,LN,T1,T2,T3,T4) \
+ PROTOCCALLSFFUN5 (T0,UN,LN,T1,T2,T3,T4,CF_0)
+#define PROTOCCALLSFFUN5( T0,UN,LN,T1,T2,T3,T4,T5) \
+ PROTOCCALLSFFUN10(T0,UN,LN,T1,T2,T3,T4,T5,CF_0,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFFUN6( T0,UN,LN,T1,T2,T3,T4,T5,T6) \
+ PROTOCCALLSFFUN10(T0,UN,LN,T1,T2,T3,T4,T5,T6,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFFUN7( T0,UN,LN,T1,T2,T3,T4,T5,T6,T7) \
+ PROTOCCALLSFFUN10(T0,UN,LN,T1,T2,T3,T4,T5,T6,T7,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFFUN8( T0,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8) \
+ PROTOCCALLSFFUN10(T0,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,CF_0,CF_0)
+#define PROTOCCALLSFFUN9( T0,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9) \
+ PROTOCCALLSFFUN10(T0,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,CF_0)
+#define PROTOCCALLSFFUN10(T0,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA) \
+ PROTOCCALLSFFUN14(T0,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,CF_0,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFFUN11(T0,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB) \
+ PROTOCCALLSFFUN14(T0,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,CF_0,CF_0,CF_0)
+#define PROTOCCALLSFFUN12(T0,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC) \
+ PROTOCCALLSFFUN14(T0,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,CF_0,CF_0)
+#define PROTOCCALLSFFUN13(T0,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD) \
+ PROTOCCALLSFFUN14(T0,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,CF_0)
+
+/* HP/UX 9.01 cc requires the blank between '_Icf(3,G,T0,UN,LN) CCCF(T1,1,0)' */
+
+#ifndef __CF__KnR
+#define PROTOCCALLSFFUN14(T0,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
+ _(T0,_cfPU)(CFC_(UN,LN))(CF_NULL_PROTO); static _Icf(2,U,T0,CFFUN(UN),0)( \
+ CFARGT14FS(UCF,HCF,_Z,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) ) \
+{ CFARGT14S(VCF,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) _(T0,_cfE) \
+ CCF(LN,T1,1) CCF(LN,T2,2) CCF(LN,T3,3) CCF(LN,T4,4) CCF(LN,T5,5) \
+ CCF(LN,T6,6) CCF(LN,T7,7) CCF(LN,T8,8) CCF(LN,T9,9) CCF(LN,TA,10) \
+ CCF(LN,TB,11) CCF(LN,TC,12) CCF(LN,TD,13) CCF(LN,TE,14) _Icf(3,G,T0,UN,LN) \
+ CFARGT14(CCCF,JCF,ABSOFT_cf1(T0),T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE)); \
+ WCF(T1,A1,1) WCF(T2,A2,2) WCF(T3,A3,3) WCF(T4,A4,4) WCF(T5,A5,5) \
+ WCF(T6,A6,6) WCF(T7,A7,7) WCF(T8,A8,8) WCF(T9,A9,9) WCF(TA,A10,10) \
+ WCF(TB,A11,11) WCF(TC,A12,12) WCF(TD,A13,13) WCF(TE,A14,14) _(T0,_cfX)}
+#else
+#define PROTOCCALLSFFUN14(T0,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
+ _(T0,_cfPU)(CFC_(UN,LN))(CF_NULL_PROTO); static _Icf(2,U,T0,CFFUN(UN),0)( \
+ CFARGT14FS(UUCF,HHCF,_Z,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) ) \
+ CFARGT14FS(UUUCF,HHHCF,_Z,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) ; \
+{ CFARGT14S(VCF,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) _(T0,_cfE) \
+ CCF(LN,T1,1) CCF(LN,T2,2) CCF(LN,T3,3) CCF(LN,T4,4) CCF(LN,T5,5) \
+ CCF(LN,T6,6) CCF(LN,T7,7) CCF(LN,T8,8) CCF(LN,T9,9) CCF(LN,TA,10) \
+ CCF(LN,TB,11) CCF(LN,TC,12) CCF(LN,TD,13) CCF(LN,TE,14) _Icf(3,G,T0,UN,LN) \
+ CFARGT14(CCCF,JCF,ABSOFT_cf1(T0),T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE)); \
+ WCF(T1,A1,1) WCF(T2,A2,2) WCF(T3,A3,3) WCF(T4,A4,4) WCF(T5,A5,5) \
+ WCF(T6,A6,6) WCF(T7,A7,7) WCF(T8,A8,8) WCF(T9,A9,9) WCF(TA,A10,10) \
+ WCF(TB,A11,11) WCF(TC,A12,12) WCF(TD,A13,13) WCF(TE,A14,14) _(T0,_cfX)}
+#endif
+
+/*-------------------------------------------------------------------------*/
+
+/* UTILITIES FOR FORTRAN TO CALL C ROUTINES */
+
+#ifdef OLD_VAXC /* Prevent %CC-I-PARAMNOTUSED. */
+#pragma nostandard
+#endif
+
+#if defined(vmsFortran) || defined(CRAYFortran)
+#define DCF(TN,I)
+#define DDCF(TN,I)
+#define DDDCF(TN,I)
+#else
+#define DCF(TN,I) HCF(TN,I)
+#define DDCF(TN,I) HHCF(TN,I)
+#define DDDCF(TN,I) HHHCF(TN,I)
+#endif
+
+#define QCF(TN,I) _(TN,_cfSTR)(1,Q,_(B,I), 0,0,0,0)
+#define DEFAULT_cfQ(B)
+#define LOGICAL_cfQ(B)
+#define PLOGICAL_cfQ(B)
+#define STRINGV_cfQ(B) char *B; unsigned int _(B,N);
+#define STRING_cfQ(B) char *B=NULL;
+#define PSTRING_cfQ(B) char *B=NULL;
+#define PSTRINGV_cfQ(B) STRINGV_cfQ(B)
+#define PNSTRING_cfQ(B) char *B=NULL;
+#define PPSTRING_cfQ(B)
+
+#ifdef __sgi /* Else SGI gives warning 182 contrary to its C LRM A.17.7 */
+#define ROUTINE_orig *(void**)&
+#else
+#define ROUTINE_orig (void *)
+#endif
+
+#define ROUTINE_1 ROUTINE_orig
+#define ROUTINE_2 ROUTINE_orig
+#define ROUTINE_3 ROUTINE_orig
+#define ROUTINE_4 ROUTINE_orig
+#define ROUTINE_5 ROUTINE_orig
+#define ROUTINE_6 ROUTINE_orig
+#define ROUTINE_7 ROUTINE_orig
+#define ROUTINE_8 ROUTINE_orig
+#define ROUTINE_9 ROUTINE_orig
+#define ROUTINE_10 ROUTINE_orig
+#define ROUTINE_11 ROUTINE_orig
+#define ROUTINE_12 ROUTINE_orig
+#define ROUTINE_13 ROUTINE_orig
+#define ROUTINE_14 ROUTINE_orig
+#define ROUTINE_15 ROUTINE_orig
+#define ROUTINE_16 ROUTINE_orig
+#define ROUTINE_17 ROUTINE_orig
+#define ROUTINE_18 ROUTINE_orig
+#define ROUTINE_19 ROUTINE_orig
+#define ROUTINE_20 ROUTINE_orig
+#define ROUTINE_21 ROUTINE_orig
+#define ROUTINE_22 ROUTINE_orig
+#define ROUTINE_23 ROUTINE_orig
+#define ROUTINE_24 ROUTINE_orig
+#define ROUTINE_25 ROUTINE_orig
+#define ROUTINE_26 ROUTINE_orig
+#define ROUTINE_27 ROUTINE_orig
+
+#define TCF(NAME,TN,I,M) _SEP_(TN,M,cfCOMMA) _(TN,_cfT)(NAME,I,_(A,I),_(B,I),_(C,I))
+#define BYTE_cfT(M,I,A,B,D) *A
+#define DOUBLE_cfT(M,I,A,B,D) *A
+#define FLOAT_cfT(M,I,A,B,D) *A
+#define INT_cfT(M,I,A,B,D) *A
+#define LOGICAL_cfT(M,I,A,B,D) F2CLOGICAL(*A)
+#define LONG_cfT(M,I,A,B,D) *A
+#define SHORT_cfT(M,I,A,B,D) *A
+#define BYTEV_cfT(M,I,A,B,D) A
+#define DOUBLEV_cfT(M,I,A,B,D) A
+#define FLOATV_cfT(M,I,A,B,D) VOIDP A
+#define INTV_cfT(M,I,A,B,D) A
+#define LOGICALV_cfT(M,I,A,B,D) A
+#define LONGV_cfT(M,I,A,B,D) A
+#define SHORTV_cfT(M,I,A,B,D) A
+#define BYTEVV_cfT(M,I,A,B,D) (void *)A /* We have to cast to void *,*/
+#define BYTEVVV_cfT(M,I,A,B,D) (void *)A /* since we don't know the */
+#define BYTEVVVV_cfT(M,I,A,B,D) (void *)A /* dimensions of the array. */
+#define BYTEVVVVV_cfT(M,I,A,B,D) (void *)A /* i.e. Unfortunately, can't */
+#define BYTEVVVVVV_cfT(M,I,A,B,D) (void *)A /* check that the type */
+#define BYTEVVVVVVV_cfT(M,I,A,B,D) (void *)A /* matches the prototype. */
+#define DOUBLEVV_cfT(M,I,A,B,D) (void *)A
+#define DOUBLEVVV_cfT(M,I,A,B,D) (void *)A
+#define DOUBLEVVVV_cfT(M,I,A,B,D) (void *)A
+#define DOUBLEVVVVV_cfT(M,I,A,B,D) (void *)A
+#define DOUBLEVVVVVV_cfT(M,I,A,B,D) (void *)A
+#define DOUBLEVVVVVVV_cfT(M,I,A,B,D) (void *)A
+#define FLOATVV_cfT(M,I,A,B,D) (void *)A
+#define FLOATVVV_cfT(M,I,A,B,D) (void *)A
+#define FLOATVVVV_cfT(M,I,A,B,D) (void *)A
+#define FLOATVVVVV_cfT(M,I,A,B,D) (void *)A
+#define FLOATVVVVVV_cfT(M,I,A,B,D) (void *)A
+#define FLOATVVVVVVV_cfT(M,I,A,B,D) (void *)A
+#define INTVV_cfT(M,I,A,B,D) (void *)A
+#define INTVVV_cfT(M,I,A,B,D) (void *)A
+#define INTVVVV_cfT(M,I,A,B,D) (void *)A
+#define INTVVVVV_cfT(M,I,A,B,D) (void *)A
+#define INTVVVVVV_cfT(M,I,A,B,D) (void *)A
+#define INTVVVVVVV_cfT(M,I,A,B,D) (void *)A
+#define LOGICALVV_cfT(M,I,A,B,D) (void *)A
+#define LOGICALVVV_cfT(M,I,A,B,D) (void *)A
+#define LOGICALVVVV_cfT(M,I,A,B,D) (void *)A
+#define LOGICALVVVVV_cfT(M,I,A,B,D) (void *)A
+#define LOGICALVVVVVV_cfT(M,I,A,B,D) (void *)A
+#define LOGICALVVVVVVV_cfT(M,I,A,B,D) (void *)A
+#define LONGVV_cfT(M,I,A,B,D) (void *)A
+#define LONGVVV_cfT(M,I,A,B,D) (void *)A
+#define LONGVVVV_cfT(M,I,A,B,D) (void *)A
+#define LONGVVVVV_cfT(M,I,A,B,D) (void *)A
+#define LONGVVVVVV_cfT(M,I,A,B,D) (void *)A
+#define LONGVVVVVVV_cfT(M,I,A,B,D) (void *)A
+#define SHORTVV_cfT(M,I,A,B,D) (void *)A
+#define SHORTVVV_cfT(M,I,A,B,D) (void *)A
+#define SHORTVVVV_cfT(M,I,A,B,D) (void *)A
+#define SHORTVVVVV_cfT(M,I,A,B,D) (void *)A
+#define SHORTVVVVVV_cfT(M,I,A,B,D) (void *)A
+#define SHORTVVVVVVV_cfT(M,I,A,B,D) (void *)A
+#define PBYTE_cfT(M,I,A,B,D) A
+#define PDOUBLE_cfT(M,I,A,B,D) A
+#define PFLOAT_cfT(M,I,A,B,D) VOIDP A
+#define PINT_cfT(M,I,A,B,D) A
+#define PLOGICAL_cfT(M,I,A,B,D) ((*A=F2CLOGICAL(*A)),A)
+#define PLONG_cfT(M,I,A,B,D) A
+#define PSHORT_cfT(M,I,A,B,D) A
+#define PVOID_cfT(M,I,A,B,D) A
+#if defined(apolloFortran) || defined(hpuxFortran800) || defined(AbsoftUNIXFortran)
+#define ROUTINE_cfT(M,I,A,B,D) _(ROUTINE_,I) (*A)
+#else
+#define ROUTINE_cfT(M,I,A,B,D) _(ROUTINE_,I) A
+#endif
+/* A == pointer to the characters
+ D == length of the string, or of an element in an array of strings
+ E == number of elements in an array of strings */
+#define TTSTR( A,B,D) \
+ ((B=_cf_malloc(D+1))[D]='\0', memcpy(B,A,D), kill_trailing(B,' '))
+#define TTTTSTR( A,B,D) (!(D<4||A[0]||A[1]||A[2]||A[3]))?NULL: \
+ memchr(A,'\0',D) ?A : TTSTR(A,B,D)
+#define TTTTSTRV( A,B,D,E) (_(B,N)=E,B=_cf_malloc(_(B,N)*(D+1)), (void *) \
+ vkill_trailing(f2cstrv(A,B,D+1, _(B,N)*(D+1)), D+1,_(B,N)*(D+1),' '))
+#ifdef vmsFortran
+#define STRING_cfT(M,I,A,B,D) TTTTSTR( A->dsc$a_pointer,B,A->dsc$w_length)
+#define STRINGV_cfT(M,I,A,B,D) TTTTSTRV(A->dsc$a_pointer, B, \
+ A->dsc$w_length , A->dsc$l_m[0])
+#define PSTRING_cfT(M,I,A,B,D) TTSTR( A->dsc$a_pointer,B,A->dsc$w_length)
+#define PPSTRING_cfT(M,I,A,B,D) A->dsc$a_pointer
+#else
+#ifdef CRAYFortran
+#define STRING_cfT(M,I,A,B,D) TTTTSTR( _fcdtocp(A),B,_fcdlen(A))
+#define STRINGV_cfT(M,I,A,B,D) TTTTSTRV(_fcdtocp(A),B,_fcdlen(A), \
+ num_elem(_fcdtocp(A),_fcdlen(A),_3(M,_STRV_A,I)))
+#define PSTRING_cfT(M,I,A,B,D) TTSTR( _fcdtocp(A),B,_fcdlen(A))
+#define PPSTRING_cfT(M,I,A,B,D) _fcdtocp(A)
+#else
+#define STRING_cfT(M,I,A,B,D) TTTTSTR( A,B,D)
+#define STRINGV_cfT(M,I,A,B,D) TTTTSTRV(A,B,D, num_elem(A,D,_3(M,_STRV_A,I)))
+#define PSTRING_cfT(M,I,A,B,D) TTSTR( A,B,D)
+#define PPSTRING_cfT(M,I,A,B,D) A
+#endif
+#endif
+#define PNSTRING_cfT(M,I,A,B,D) STRING_cfT(M,I,A,B,D)
+#define PSTRINGV_cfT(M,I,A,B,D) STRINGV_cfT(M,I,A,B,D)
+#define CF_0_cfT(M,I,A,B,D)
+
+#define RCF(TN,I) _(TN,_cfSTR)(3,R,_(A,I),_(B,I),_(C,I),0,0)
+#define DEFAULT_cfR(A,B,D)
+#define LOGICAL_cfR(A,B,D)
+#define PLOGICAL_cfR(A,B,D) *A=C2FLOGICAL(*A);
+#define STRING_cfR(A,B,D) if (B) _cf_free(B);
+#define STRINGV_cfR(A,B,D) _cf_free(B);
+/* A and D as defined above for TSTRING(V) */
+#define RRRRPSTR( A,B,D) if (B) memcpy(A,B, _cfMIN(strlen(B),D)), \
+ (D>strlen(B)?memset(A+strlen(B),' ', D-strlen(B)):0), _cf_free(B);
+#define RRRRPSTRV(A,B,D) c2fstrv(B,A,D+1,(D+1)*_(B,N)), _cf_free(B);
+#ifdef vmsFortran
+#define PSTRING_cfR(A,B,D) RRRRPSTR( A->dsc$a_pointer,B,A->dsc$w_length)
+#define PSTRINGV_cfR(A,B,D) RRRRPSTRV(A->dsc$a_pointer,B,A->dsc$w_length)
+#else
+#ifdef CRAYFortran
+#define PSTRING_cfR(A,B,D) RRRRPSTR( _fcdtocp(A),B,_fcdlen(A))
+#define PSTRINGV_cfR(A,B,D) RRRRPSTRV(_fcdtocp(A),B,_fcdlen(A))
+#else
+#define PSTRING_cfR(A,B,D) RRRRPSTR( A,B,D)
+#define PSTRINGV_cfR(A,B,D) RRRRPSTRV(A,B,D)
+#endif
+#endif
+#define PNSTRING_cfR(A,B,D) PSTRING_cfR(A,B,D)
+#define PPSTRING_cfR(A,B,D)
+
+#define BYTE_cfFZ(UN,LN) INTEGER_BYTE FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#define DOUBLE_cfFZ(UN,LN) DOUBLE_PRECISION FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#define INT_cfFZ(UN,LN) int FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#define LOGICAL_cfFZ(UN,LN) int FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#define LONG_cfFZ(UN,LN) long FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#define SHORT_cfFZ(UN,LN) short FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#define VOID_cfFZ(UN,LN) void FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#ifndef __CF__KnR
+/* The void is req'd by the Apollo, to make this an ANSI function declaration.
+ The Apollo promotes K&R float functions to double. */
+#define FLOAT_cfFZ(UN,LN) FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(void
+#ifdef vmsFortran
+#define STRING_cfFZ(UN,LN) void FCALLSC_QUALIFIER fcallsc(UN,LN)(fstring *AS
+#else
+#ifdef CRAYFortran
+#define STRING_cfFZ(UN,LN) void FCALLSC_QUALIFIER fcallsc(UN,LN)(_fcd AS
+#else
+#if defined(AbsoftUNIXFortran) || defined(AbsoftProFortran)
+#define STRING_cfFZ(UN,LN) void FCALLSC_QUALIFIER fcallsc(UN,LN)(char *AS
+#else
+#define STRING_cfFZ(UN,LN) void FCALLSC_QUALIFIER fcallsc(UN,LN)(char *AS, unsigned D0
+#endif
+#endif
+#endif
+#else
+#if ! (defined(FLOATFUNCTIONTYPE)&&defined(ASSIGNFLOAT)&&defined(RETURNFLOAT))
+#define FLOAT_cfFZ(UN,LN) FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#else
+#define FLOAT_cfFZ(UN,LN) FLOATFUNCTIONTYPE FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#endif
+#if defined(vmsFortran) || defined(CRAYFortran) || defined(AbsoftUNIXFortran)
+#define STRING_cfFZ(UN,LN) void FCALLSC_QUALIFIER fcallsc(UN,LN)(AS
+#else
+#define STRING_cfFZ(UN,LN) void FCALLSC_QUALIFIER fcallsc(UN,LN)(AS, D0
+#endif
+#endif
+
+#define BYTE_cfF(UN,LN) BYTE_cfFZ(UN,LN)
+#define DOUBLE_cfF(UN,LN) DOUBLE_cfFZ(UN,LN)
+#ifndef __CF_KnR
+#define FLOAT_cfF(UN,LN) FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#else
+#define FLOAT_cfF(UN,LN) FLOAT_cfFZ(UN,LN)
+#endif
+#define INT_cfF(UN,LN) INT_cfFZ(UN,LN)
+#define LOGICAL_cfF(UN,LN) LOGICAL_cfFZ(UN,LN)
+#define LONG_cfF(UN,LN) LONG_cfFZ(UN,LN)
+#define SHORT_cfF(UN,LN) SHORT_cfFZ(UN,LN)
+#define VOID_cfF(UN,LN) VOID_cfFZ(UN,LN)
+#define STRING_cfF(UN,LN) STRING_cfFZ(UN,LN),
+
+#define INT_cfFF
+#define VOID_cfFF
+#ifdef vmsFortran
+#define STRING_cfFF fstring *AS;
+#else
+#ifdef CRAYFortran
+#define STRING_cfFF _fcd AS;
+#else
+#define STRING_cfFF char *AS; unsigned D0;
+#endif
+#endif
+
+#define INT_cfL A0=
+#define STRING_cfL A0=
+#define VOID_cfL
+
+#define INT_cfK
+#define VOID_cfK
+/* KSTRING copies the string into the position provided by the caller. */
+#ifdef vmsFortran
+#define STRING_cfK \
+ memcpy(AS->dsc$a_pointer,A0,_cfMIN(AS->dsc$w_length,(A0==NULL?0:strlen(A0))));\
+ AS->dsc$w_length>(A0==NULL?0:strlen(A0))? \
+ memset(AS->dsc$a_pointer+(A0==NULL?0:strlen(A0)),' ', \
+ AS->dsc$w_length-(A0==NULL?0:strlen(A0))):0;
+#else
+#ifdef CRAYFortran
+#define STRING_cfK \
+ memcpy(_fcdtocp(AS),A0, _cfMIN(_fcdlen(AS),(A0==NULL?0:strlen(A0))) ); \
+ _fcdlen(AS)>(A0==NULL?0:strlen(A0))? \
+ memset(_fcdtocp(AS)+(A0==NULL?0:strlen(A0)),' ', \
+ _fcdlen(AS)-(A0==NULL?0:strlen(A0))):0;
+#else
+#define STRING_cfK memcpy(AS,A0, _cfMIN(D0,(A0==NULL?0:strlen(A0))) ); \
+ D0>(A0==NULL?0:strlen(A0))?memset(AS+(A0==NULL?0:strlen(A0)), \
+ ' ', D0-(A0==NULL?0:strlen(A0))):0;
+#endif
+#endif
+
+/* Note that K.. and I.. can't be combined since K.. has to access data before
+R.., in order for functions returning strings which are also passed in as
+arguments to work correctly. Note that R.. frees and hence may corrupt the
+string. */
+#define BYTE_cfI return A0;
+#define DOUBLE_cfI return A0;
+#if ! (defined(FLOATFUNCTIONTYPE)&&defined(ASSIGNFLOAT)&&defined(RETURNFLOAT))
+#define FLOAT_cfI return A0;
+#else
+#define FLOAT_cfI RETURNFLOAT(A0);
+#endif
+#define INT_cfI return A0;
+#ifdef hpuxFortran800
+/* Incredibly, functions must return true as 1, elsewhere .true.==0x01000000. */
+#define LOGICAL_cfI return ((A0)?1:0);
+#else
+#define LOGICAL_cfI return C2FLOGICAL(A0);
+#endif
+#define LONG_cfI return A0;
+#define SHORT_cfI return A0;
+#define STRING_cfI return ;
+#define VOID_cfI return ;
+
+#ifdef OLD_VAXC /* Allow %CC-I-PARAMNOTUSED. */
+#pragma standard
+#endif
+
+#define FCALLSCSUB0( CN,UN,LN) FCALLSCFUN0(VOID,CN,UN,LN)
+#define FCALLSCSUB1( CN,UN,LN,T1) FCALLSCFUN1(VOID,CN,UN,LN,T1)
+#define FCALLSCSUB2( CN,UN,LN,T1,T2) FCALLSCFUN2(VOID,CN,UN,LN,T1,T2)
+#define FCALLSCSUB3( CN,UN,LN,T1,T2,T3) FCALLSCFUN3(VOID,CN,UN,LN,T1,T2,T3)
+#define FCALLSCSUB4( CN,UN,LN,T1,T2,T3,T4) \
+ FCALLSCFUN4(VOID,CN,UN,LN,T1,T2,T3,T4)
+#define FCALLSCSUB5( CN,UN,LN,T1,T2,T3,T4,T5) \
+ FCALLSCFUN5(VOID,CN,UN,LN,T1,T2,T3,T4,T5)
+#define FCALLSCSUB6( CN,UN,LN,T1,T2,T3,T4,T5,T6) \
+ FCALLSCFUN6(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6)
+#define FCALLSCSUB7( CN,UN,LN,T1,T2,T3,T4,T5,T6,T7) \
+ FCALLSCFUN7(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7)
+#define FCALLSCSUB8( CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8) \
+ FCALLSCFUN8(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8)
+#define FCALLSCSUB9( CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9) \
+ FCALLSCFUN9(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9)
+#define FCALLSCSUB10(CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA) \
+ FCALLSCFUN10(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA)
+#define FCALLSCSUB11(CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB) \
+ FCALLSCFUN11(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB)
+#define FCALLSCSUB12(CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC) \
+ FCALLSCFUN12(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC)
+#define FCALLSCSUB13(CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD) \
+ FCALLSCFUN13(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD)
+#define FCALLSCSUB14(CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
+ FCALLSCFUN14(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE)
+#define FCALLSCSUB15(CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF) \
+ FCALLSCFUN15(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF)
+#define FCALLSCSUB16(CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG) \
+ FCALLSCFUN16(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG)
+#define FCALLSCSUB17(CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH) \
+ FCALLSCFUN17(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH)
+#define FCALLSCSUB18(CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI) \
+ FCALLSCFUN18(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI)
+#define FCALLSCSUB19(CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ) \
+ FCALLSCFUN19(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ)
+#define FCALLSCSUB20(CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK) \
+ FCALLSCFUN20(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK)
+#define FCALLSCSUB21(CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL) \
+ FCALLSCFUN21(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL)
+#define FCALLSCSUB22(CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM) \
+ FCALLSCFUN22(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM)
+#define FCALLSCSUB23(CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN) \
+ FCALLSCFUN23(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN)
+#define FCALLSCSUB24(CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO) \
+ FCALLSCFUN24(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO)
+#define FCALLSCSUB25(CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP) \
+ FCALLSCFUN25(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP)
+#define FCALLSCSUB26(CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ) \
+ FCALLSCFUN26(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ)
+#define FCALLSCSUB27(CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR) \
+ FCALLSCFUN27(VOID,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR)
+
+
+#define FCALLSCFUN1( T0,CN,UN,LN,T1) \
+ FCALLSCFUN5 (T0,CN,UN,LN,T1,CF_0,CF_0,CF_0,CF_0)
+#define FCALLSCFUN2( T0,CN,UN,LN,T1,T2) \
+ FCALLSCFUN5 (T0,CN,UN,LN,T1,T2,CF_0,CF_0,CF_0)
+#define FCALLSCFUN3( T0,CN,UN,LN,T1,T2,T3) \
+ FCALLSCFUN5 (T0,CN,UN,LN,T1,T2,T3,CF_0,CF_0)
+#define FCALLSCFUN4( T0,CN,UN,LN,T1,T2,T3,T4) \
+ FCALLSCFUN5 (T0,CN,UN,LN,T1,T2,T3,T4,CF_0)
+#define FCALLSCFUN5( T0,CN,UN,LN,T1,T2,T3,T4,T5) \
+ FCALLSCFUN10(T0,CN,UN,LN,T1,T2,T3,T4,T5,CF_0,CF_0,CF_0,CF_0,CF_0)
+#define FCALLSCFUN6( T0,CN,UN,LN,T1,T2,T3,T4,T5,T6) \
+ FCALLSCFUN10(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,CF_0,CF_0,CF_0,CF_0)
+#define FCALLSCFUN7( T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7) \
+ FCALLSCFUN10(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,CF_0,CF_0,CF_0)
+#define FCALLSCFUN8( T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8) \
+ FCALLSCFUN10(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,CF_0,CF_0)
+#define FCALLSCFUN9( T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9) \
+ FCALLSCFUN10(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,CF_0)
+#define FCALLSCFUN10(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA) \
+ FCALLSCFUN14(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,CF_0,CF_0,CF_0,CF_0)
+#define FCALLSCFUN11(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB) \
+ FCALLSCFUN14(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,CF_0,CF_0,CF_0)
+#define FCALLSCFUN12(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC) \
+ FCALLSCFUN14(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,CF_0,CF_0)
+#define FCALLSCFUN13(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD) \
+ FCALLSCFUN14(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,CF_0)
+
+
+#define FCALLSCFUN15(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF) \
+ FCALLSCFUN20(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,CF_0,CF_0,CF_0,CF_0,CF_0)
+#define FCALLSCFUN16(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG) \
+ FCALLSCFUN20(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,CF_0,CF_0,CF_0,CF_0)
+#define FCALLSCFUN17(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH) \
+ FCALLSCFUN20(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,CF_0,CF_0,CF_0)
+#define FCALLSCFUN18(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI) \
+ FCALLSCFUN20(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,CF_0,CF_0)
+#define FCALLSCFUN19(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ) \
+ FCALLSCFUN20(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,CF_0)
+#define FCALLSCFUN20(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK) \
+ FCALLSCFUN27(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0)
+#define FCALLSCFUN21(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL) \
+ FCALLSCFUN27(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,CF_0,CF_0,CF_0,CF_0,CF_0,CF_0)
+#define FCALLSCFUN22(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM) \
+ FCALLSCFUN27(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,CF_0,CF_0,CF_0,CF_0,CF_0)
+#define FCALLSCFUN23(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN) \
+ FCALLSCFUN27(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,CF_0,CF_0,CF_0,CF_0)
+#define FCALLSCFUN24(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO) \
+ FCALLSCFUN27(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,CF_0,CF_0,CF_0)
+#define FCALLSCFUN25(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP) \
+ FCALLSCFUN27(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,CF_0,CF_0)
+#define FCALLSCFUN26(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ) \
+ FCALLSCFUN27(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,CF_0)
+
+
+#ifndef __CF__KnR
+#define FCALLSCFUN0(T0,CN,UN,LN) CFextern _(T0,_cfFZ)(UN,LN) ABSOFT_cf2(T0)) \
+ {_Icf(2,UU,T0,A0,0); _Icf(0,L,T0,0,0) CN(); _Icf(0,K,T0,0,0) _(T0,_cfI)}
+
+#define FCALLSCFUN14(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
+ CFextern _(T0,_cfF)(UN,LN) \
+ CFARGT14(NCF,DCF,ABSOFT_cf2(T0),T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) ) \
+ { CFARGT14S(QCF,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
+ _Icf(2,UU,T0,A0,0); _Icf(0,L,T0,0,0) CN( TCF(LN,T1,1,0) TCF(LN,T2,2,1) \
+ TCF(LN,T3,3,1) TCF(LN,T4,4,1) TCF(LN,T5,5,1) TCF(LN,T6,6,1) TCF(LN,T7,7,1) \
+ TCF(LN,T8,8,1) TCF(LN,T9,9,1) TCF(LN,TA,10,1) TCF(LN,TB,11,1) TCF(LN,TC,12,1) \
+ TCF(LN,TD,13,1) TCF(LN,TE,14,1) ); _Icf(0,K,T0,0,0) \
+ CFARGT14S(RCF,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) _(T0,_cfI) }
+
+#define FCALLSCFUN27(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR) \
+ CFextern _(T0,_cfF)(UN,LN) \
+ CFARGT27(NCF,DCF,ABSOFT_cf2(T0),T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR) ) \
+ { CFARGT27S(QCF,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR) \
+ _Icf(2,UU,T0,A0,0); _Icf(0,L,T0,0,0) CN( TCF(LN,T1,1,0) TCF(LN,T2,2,1) \
+ TCF(LN,T3,3,1) TCF(LN,T4,4,1) TCF(LN,T5,5,1) TCF(LN,T6,6,1) TCF(LN,T7,7,1) \
+ TCF(LN,T8,8,1) TCF(LN,T9,9,1) TCF(LN,TA,10,1) TCF(LN,TB,11,1) TCF(LN,TC,12,1) \
+ TCF(LN,TD,13,1) TCF(LN,TE,14,1) TCF(LN,TF,15,1) TCF(LN,TG,16,1) TCF(LN,TH,17,1) \
+ TCF(LN,TI,18,1) TCF(LN,TJ,19,1) TCF(LN,TK,20,1) TCF(LN,TL,21,1) TCF(LN,TM,22,1) \
+ TCF(LN,TN,23,1) TCF(LN,TO,24,1) TCF(LN,TP,25,1) TCF(LN,TQ,26,1) TCF(LN,TR,27,1) ); _Icf(0,K,T0,0,0) \
+ CFARGT27S(RCF,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR) _(T0,_cfI) }
+
+#else
+#define FCALLSCFUN0(T0,CN,UN,LN) CFextern _(T0,_cfFZ)(UN,LN) ABSOFT_cf3(T0)) _Icf(0,FF,T0,0,0)\
+ {_Icf(2,UU,T0,A0,0); _Icf(0,L,T0,0,0) CN(); _Icf(0,K,T0,0,0) _(T0,_cfI)}
+
+#define FCALLSCFUN14(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
+ CFextern _(T0,_cfF)(UN,LN) \
+ CFARGT14(NNCF,DDCF,ABSOFT_cf3(T0),T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE)) _Icf(0,FF,T0,0,0) \
+ CFARGT14FS(NNNCF,DDDCF,_Z,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE); \
+ { CFARGT14S(QCF,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) \
+ _Icf(2,UU,T0,A0,0); _Icf(0,L,T0,0,0) CN( TCF(LN,T1,1,0) TCF(LN,T2,2,1) \
+ TCF(LN,T3,3,1) TCF(LN,T4,4,1) TCF(LN,T5,5,1) TCF(LN,T6,6,1) TCF(LN,T7,7,1) \
+ TCF(LN,T8,8,1) TCF(LN,T9,9,1) TCF(LN,TA,10,1) TCF(LN,TB,11,1) TCF(LN,TC,12,1) \
+ TCF(LN,TD,13,1) TCF(LN,TE,14,1) ); _Icf(0,K,T0,0,0) \
+ CFARGT14S(RCF,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE) _(T0,_cfI)}
+
+#define FCALLSCFUN27(T0,CN,UN,LN,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR) \
+ CFextern _(T0,_cfF)(UN,LN) \
+ CFARGT27(NNCF,DDCF,ABSOFT_cf3(T0),T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR)) _Icf(0,FF,T0,0,0) \
+ CFARGT27FS(NNNCF,DDDCF,_Z,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR); \
+ { CFARGT27S(QCF,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR) \
+ _Icf(2,UU,T0,A0,0); _Icf(0,L,T0,0,0) CN( TCF(LN,T1,1,0) TCF(LN,T2,2,1) \
+ TCF(LN,T3,3,1) TCF(LN,T4,4,1) TCF(LN,T5,5,1) TCF(LN,T6,6,1) TCF(LN,T7,7,1) \
+ TCF(LN,T8,8,1) TCF(LN,T9,9,1) TCF(LN,TA,10,1) TCF(LN,TB,11,1) TCF(LN,TC,12,1) \
+ TCF(LN,TD,13,1) TCF(LN,TE,14,1) TCF(LN,TF,15,1) TCF(LN,TG,16,1) TCF(LN,TH,17,1) \
+ TCF(LN,TI,18,1) TCF(LN,TJ,19,1) TCF(LN,TK,20,1) TCF(LN,TL,21,1) TCF(LN,TM,22,1) \
+ TCF(LN,TN,23,1) TCF(LN,TO,24,1) TCF(LN,TP,25,1) TCF(LN,TQ,26,1) TCF(LN,TR,27,1) ); _Icf(0,K,T0,0,0) \
+ CFARGT27S(RCF,T1,T2,T3,T4,T5,T6,T7,T8,T9,TA,TB,TC,TD,TE,TF,TG,TH,TI,TJ,TK,TL,TM,TN,TO,TP,TQ,TR) _(T0,_cfI)}
+
+#endif
+
+
+#endif /* __CFORTRAN_LOADED */
diff --git a/include/cdTime/drscdf.h b/include/cdTime/drscdf.h
new file mode 100644
index 0000000..41163d4
--- /dev/null
+++ b/include/cdTime/drscdf.h
@@ -0,0 +1,272 @@
+/*
+ $Id$
+ $Log: drscdf.h,v $
+ * 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/include/cdTime/drsdef.h b/include/cdTime/drsdef.h
new file mode 100644
index 0000000..291ec46
--- /dev/null
+++ b/include/cdTime/drsdef.h
@@ -0,0 +1,203 @@
+c drsdef.H,v 2.7 1995/10/26 23:23:21 drach Exp
+c drsdef.H,v
+c Revision 2.7 1995/10/26 23:23:21 drach
+c - Added IDRS_NOCOPY aslun flag, NSL version
+c
+c Revision 2.6 1995/10/16 18:47:44 drach
+c - Modified for DEC Alpha
+c
+c Revision 2.5 1995/03/30 00:50:37 drach
+c Added disclaimer
+c
+c Revision 2.4 1993/10/21 01:23:26 drach
+c changed name of sync options for consistency, added sync error.
+c
+c Revision 2.3 1993/10/20 17:17:14 drach
+c Add autosync options.
+c
+c Revision 2.2 1993/07/14 22:35:35 drach
+c Corrected CVS comment header.
+c
+c * Revision 2.1 1993/07/14 22:33:20 drach
+c * Replaced drsdef.h with drsdef.H
+c *
+c Revision 2.2 1993/07/13 17:53:31 drach
+c Fixed up CVS install
+c
+c * Revision 2.1 1993/07/13 01:12:49 drach
+c * Merged Sun, Unicos, SGI, and HP versions.
+c *
+c Revision 2.4 1992/10/15 00:17:34 drach
+c Corrected misspelling
+c
+c Revision 2.3 1992/10/14 23:15:39 drach
+c Added putdic options.
+c
+c Revision 2.2 1992/10/06 00:54:25 drach
+c Added putdic errors.
+c
+c Revision 2.1 1992/05/22 01:08:29 drach
+c Removed drsmsg (error messages), moved to drserr.f
+c
+c Revision 2.0 1992/03/07 00:10:39 drach
+c Entered into RCS
+c
+c
+c Data Retrieval and Storage System
+c
+c**********************************************************************
+c
+c DISCLAIMER
+c
+c This software was prepared as an account of work sponsored by an
+c agency of the United States Government. Neither the United
+c States Government nor the University of California nor any of
+c their employees, makes any warranty, express or implied, or
+c assumes any liability or responsibility for the accuracy,
+c completeness, or usefulness of any information, apparatus,
+c product, or process disclosed, or represents that its use would
+c not infringe privately owned rights. Reference herein to any
+c specific commercial products, process, or service by trade name,
+c trademark, manufacturer, or otherwise, does not necessarily
+c constitute or imply its endorsement, recommendation, or favoring
+c by the United States Government or the University of California.
+c The views and opinions of authors expressed herein do not
+c necessarily state or reflect those of the United States
+c Government or the University of California, and shall not be
+c used for advertising or product endorsement purposes.
+c
+c**********************************************************************
+c
+c#######################################################################
+c drsdef.h
+
+c#######################################################################
+c General definitions
+ parameter(IDRS_NOVALUE=0
+ $ ,IDRS_DEFAULT=0
+ $ )
+
+c DimensionType
+ parameter (IDRS_EQUALLY_SPACED = 1,
+ $ IDRS_UNEQUALLY_SPACED = 2)
+
+c FileStatus
+ parameter (IDRS_READ = 1,
+ $ IDRS_CREATE = 2,
+ $ IDRS_EXTEND = 3)
+
+c MachineName
+ parameter (IDRS_SUN = 1,
+ $ IDRS_CRAY = 2)
+
+ parameter (IDRS_MACHINE=IDRS_SUN,
+ $ IDRS_BYTES_PER_WORD=4
+ $ )
+c see GETIND
+ parameter (IDRS_MAXPATH=1024)
+
+ character*8 DRS_FILETAG
+
+c DRSVersion
+c DRS_VERSION is current version
+c DRS_MAXVERSION is max allowed version before version
+c is considered *novalue*
+ parameter(DRS_VERSION=2.1,
+ $ DRS_MAXVERSION=10.0,
+ $ DRS_FILETAG='DRS DATA'
+ $ )
+
+c Inquiry operators (INQDICT)
+ parameter(IDRS_GETFIRSTVAR=1
+ $ ,IDRS_GETNEXTVAR=2
+ $ )
+
+c Cray-to-IEEE translation parameters
+ parameter(IDRS_LEFTHALFWORD=0
+ $ ,IDRS_RIGHTHALFWORD=4
+ $ )
+
+c ElementType
+ parameter(IDRS_I4=1
+ $ ,IDRS_I8=2
+ $ ,IDRS_IEEE_R4=3
+ $ ,IDRS_CRAY_R8=4
+ $ ,IDRS_ASCII=5
+ $ ,IDRS_USER=6
+ $ )
+
+c Synchronization options
+ parameter(IDRS_SYNC_OFF=1
+ $ ,IDRS_SYNC_ON=2)
+
+c Error reporting
+ parameter (IDRS_NOREPORT=1
+ $ ,IDRS_FATAL=2
+ $ ,IDRS_WARNING=3
+ $ ,IDRS_INTERNAL=4
+ $ )
+
+c Putdic options
+ parameter (IDRS_BLANKS_ARE_NULL=1
+ $ ,IDRS_BLANKS_ARE_LITERAL=2
+ $ )
+
+c Error definitions
+ parameter (IDRS_SUCCESS=0
+ $ ,IDRS_NOMEMORY=1
+ $ ,IDRS_BINFAILED=2002
+ $ ,IDRS_BADLEN=3
+ $ ,IDRS_NOMONO=4
+ $ ,IDRS_NOCOMPARISON=2005
+ $ ,IDRS_VDBNOTFOUND=6
+ $ ,IDRS_BADDIM=7
+ $ ,IDRS_NOTMONOTONE=8
+ $ ,IDRS_DICTREADERROR=9)
+ parameter (IDRS_NODICTFILE=10
+ $ ,IDRS_BADLU=11
+ $ ,IDRS_BADTYPE=12
+ $ ,IDRS_AMBIGUITYEXISTS=13
+ $ ,IDRS_CANNOTADDDATA=14
+ $ ,IDRS_DICTFULL=15
+ $ ,IDRS_VERSION1FILE=1016
+ $ ,IDRS_NEWFILEFORMAT=1017
+ $ ,IDRS_CANNOTREADHEADER=18
+ $ ,IDRS_CANNOTREADDATA=19)
+ parameter(IDRS_BADDIMNAME=20
+ $ ,IDRS_TOOMANYFILES=21
+ $ ,IDRS_CANNOTOPENDICT=22
+ $ ,IDRS_CANNOTOPENDATA=23
+ $ ,IDRS_BADSTATUS=24
+ $ ,IDRS_BADDIMTYPE=25
+ $ ,IDRS_INDEXHIGH=2026
+ $ ,IDRS_INDEXLOW=2027
+ $ ,IDRS_INDEXBETWEEN=2028
+ $ ,IDRS_NORANGE=29)
+ parameter(IDRS_SAVEBUFOVERFLOW=30
+ $ ,IDRS_BADERRLEVEL=31
+ $ ,IDRS_ERROROUTOFRANGE=32
+ $ ,IDRS_CANNOTWRITEHEADER=33
+ $ ,IDRS_CANNOTWRITEDATA=34
+ $ ,IDRS_BADCHARLEN=35
+ $ ,IDRS_BADOPER=36
+ $ ,IDRS_NOMOREVARS=1037
+ $ ,IDRS_DICTALREADYOPEN=38
+ $ ,IDRS_LOOKUPFAILED=2039
+ $ )
+ parameter(IDRS_DICTWRITEERROR=40
+ $ ,IDRS_DICTEXTENDERROR=41
+ $ ,IDRS_DATEXTENDERROR=42
+ $ ,IDRS_DICTRUNCATEERR=43
+ $ ,IDRS_DATTRUNCATEERR=44
+ $ ,IDRS_BADIEEEFP=1045
+ $ ,IDRS_BADCRAYFP=1046
+ $ ,IDRS_BADCRAYINT=1047
+ $ ,IDRS_CANNOTCONVERT=48
+ $ ,IDRS_INEXACTMATCH=1049
+ $ )
+ parameter(IDRS_DUPLICATEVAR=50
+ $ ,IDRS_CANNOTWRITEDIC=51
+ $ ,IDRS_BADSYNCOPT=52
+ $ ,IDRS_LASTERROR=53
+ $ )
+
diff --git a/include/cdTime/fcddrs.h b/include/cdTime/fcddrs.h
new file mode 100644
index 0000000..93b9f09
--- /dev/null
+++ b/include/cdTime/fcddrs.h
@@ -0,0 +1,219 @@
+c -*-Mode: Fortran;-*-
+c Module: fcddrs.h - Fortran include file for DRS wrapper routines
+c
+c Copyright: 1994, Regents of the University of California
+c This software may not be distributed to others without
+c permission of the author.
+c
+c Author: Bob Drach, Lawrence Livermore National Laboratory
+c drach at llnl.gov
+c
+c Version: fcddrs.h,v 1.3 1995/03/31 06:53:25 drach Exp
+c
+c Revision History:
+c
+c fcddrs.h,v
+c Revision 1.3 1995/03/31 06:53:25 drach
+c Ported to HP9000
+c
+c Revision 1.2 1995/02/15 20:55:29 drach
+c - Added IDRS_VECTOR as synonym for IDRS_UNEQUALLY_SPACED
+c
+c Revision 1.1 1995/01/30 17:50:49 drach
+c - Initial version
+c
+c
+c
+
+ real CW_FLOAT_NULL
+ integer CW_INT_NULL
+ integer CW_C_MAJORITY, CW_FORTRAN_MAJORITY
+ parameter(CW_FLOAT_NULL=1.0e20)
+ parameter(CW_INT_NULL=0)
+ parameter(CW_C_MAJORITY = 1, CW_FORTRAN_MAJORITY = 2)
+ parameter(IDRS_VECTOR = 2)
+
+c Extended element types
+ parameter(IDRS_I1 = 7
+ $ ,IDRS_I2 = 8
+ $ ,IDRS_IEEE_R8 = 9
+ $ ,IDRS_CRAY_R16 = 10
+ $ ,IDRS_IEEE_R16 = 11
+ $ )
+
+#if (defined(hpux) || defined(ibm)) || defined(__linux_absoft)
+
+#ifndef NO_DECLARE
+
+ integer cw_aslun_
+ integer cw_cllun_
+ integer cw_cluvdb_
+ logical cw_drstest_
+ integer cw_getdat_
+ integer cw_getcdim_
+ integer cw_getcdimD_
+ integer cw_getedim_
+ integer cw_getedimD_
+ integer cw_getelemd_
+ integer cw_getname_
+ integer cw_getnd_
+ integer cw_getrge2_
+ integer cw_getrge2D_
+ integer cw_getslab_
+ integer cw_inqdict_
+ integer cw_inqlun_
+ integer cw_majority_
+ integer cw_setdim_
+ integer cw_seterr_
+ integer cw_setname_
+ integer cw_setvdim_
+ integer cw_putdat_
+ integer cw_putdic_
+ integer cw_putvdim_
+ integer cw_setdate_
+ integer cw_setrep_
+
+#endif
+
+#ifndef _fcddrs_h
+#define _fcddrs_h
+
+#define cw_aslun cw_aslun_
+#define cw_cllun cw_cllun_
+#define cw_cluvdb cw_cluvdb_
+#define cw_drstest cw_drstest_
+#define cw_getdat cw_getdat_
+#define cw_getcdim cw_getcdim_
+#define cw_getcdimD cw_getcdimD_
+#define cw_getedim cw_getedim_
+#define cw_getedimD cw_getedimD_
+#define cw_getelemd cw_getelemd_
+#define cw_getname cw_getname_
+#define cw_getnd cw_getnd_
+#define cw_getrge2 cw_getrge2_
+#define cw_getrge2D cw_getrge2D_
+#define cw_getslab cw_getslab_
+#define cw_inqdict cw_inqdict_
+#define cw_inqlun cw_inqlun_
+#define cw_majority cw_majority_
+#define cw_setdim cw_setdim_
+#define cw_seterr cw_seterr_
+#define cw_setname cw_setname_
+#define cw_setvdim cw_setvdim_
+#define cw_putdat cw_putdat_
+#define cw_putdic cw_putdic_
+#define cw_putvdim cw_putvdim_
+#define cw_setdate cw_setdate_
+#define cw_setrep cw_setrep_
+#endif
+
+#else
+
+#ifndef NO_DECLARE
+
+ integer cw_aslun
+ integer cw_cllun
+ integer cw_cluvdb
+ logical cw_drstest
+ integer cw_getdat
+ integer cw_getcdim
+ integer cw_getcdimD
+ integer cw_getedim
+ integer cw_getedimD
+ integer cw_getelemd
+ integer cw_getname
+ integer cw_getnd
+ integer cw_getrge2
+ integer cw_getrge2D
+ integer cw_getslab
+ integer cw_inqdict
+ integer cw_inqlun
+ integer cw_majority
+ integer cw_setdim
+ integer cw_seterr
+ integer cw_setname
+ integer cw_setvdim
+ integer cw_putdat
+ integer cw_putdic
+ integer cw_putvdim
+ integer cw_setdate
+ integer cw_setrep
+
+#endif
+
+#endif
+
+#ifdef CDCOMPAT
+#if (defined(hpux) || defined(ibm)) || defined(__linux_absoft)
+
+#ifndef _fcddrs_h
+#define _fcddrs_h
+
+#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 getrge2D cw_getrge2D_
+#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
+
+#else
+
+#ifndef _fcddrs_h
+#define _fcddrs_h
+
+#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 getrge2D cw_getrge2D
+#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
+
+#endif
diff --git a/include/cdTime/gaussLats.h b/include/cdTime/gaussLats.h
new file mode 100644
index 0000000..4dc395e
--- /dev/null
+++ b/include/cdTime/gaussLats.h
@@ -0,0 +1,232 @@
+/* -*-Mode: C;-*-
+ * Module: gausslats.h - Definitions of Gaussian latitudes.
+ *
+ * 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$
+ *
+ * Revision History:
+ *
+ * $Log: gaussLats.h,v $
+ * Revision 1.2 1994/10/25 00:59:13 drach
+ * - Added R40 grid
+ *
+ * Revision 1.1 1994/08/12 21:45:48 drach
+ * Entered into CVS
+ *
+ *
+ */
+
+
+
+#define T21_LEN 32
+#define R15_LEN 40
+#define T32_LEN 48
+#define R21_LEN 56
+#define T42_LEN 64
+#define R31_LEN 80
+#define T63_LEN 96
+#define R40_LEN 102
+#define T106_LEN 160
+
+static double t21Lats[T21_LEN+2] = { 90.0,
+ 0.85760587120445E+02, 0.80268779072251E+02, 0.74744540368636E+02, 0.69212976169371E+02,
+ 0.63678635561097E+02, 0.58142954049203E+02, 0.52606526034345E+02, 0.47069642059688E+02,
+ 0.41532461246656E+02, 0.35995078411272E+02, 0.30457553961152E+02, 0.24919928629948E+02,
+ 0.19382231346434E+02, 0.13844483734385E+02, 0.83067028565188E+01, 0.27689030077360E+01,
+-0.27689030077360E+01,-0.83067028565188E+01,-0.13844483734385E+02,-0.19382231346434E+02,
+-0.24919928629948E+02,-0.30457553961152E+02,-0.35995078411272E+02,-0.41532461246656E+02,
+-0.47069642059688E+02,-0.52606526034345E+02,-0.58142954049203E+02,-0.63678635561097E+02,
+-0.69212976169371E+02,-0.74744540368636E+02,-0.80268779072251E+02,-0.85760587120445E+02,
+ -90.0};
+
+static double r15Lats[R15_LEN+2] = { 90.0,
+ 0.86597954212835E+02, 0.82190885554948E+02, 0.77757791251976E+02, 0.73318817296172E+02,
+ 0.68877613808930E+02, 0.64435332287914E+02, 0.59992449212443E+02, 0.55549197158977E+02,
+ 0.51105703159234E+02, 0.46662042537064E+02, 0.42218262871435E+02, 0.37774395783429E+02,
+ 0.33330463202456E+02, 0.28886480912748E+02, 0.24442460668163E+02, 0.19998411511672E+02,
+ 0.15554340633426E+02, 0.11110253951903E+02, 0.66661565251761E+01, 0.22220528574090E+01,
+-0.22220528574090E+01,-0.66661565251761E+01,-0.11110253951903E+02,-0.15554340633426E+02,
+-0.19998411511672E+02,-0.24442460668163E+02,-0.28886480912748E+02,-0.33330463202456E+02,
+-0.37774395783429E+02,-0.42218262871435E+02,-0.46662042537064E+02,-0.51105703159234E+02,
+-0.55549197158977E+02,-0.59992449212443E+02,-0.64435332287914E+02,-0.68877613808930E+02,
+-0.73318817296172E+02,-0.77757791251976E+02,-0.82190885554948E+02,-0.86597954212835E+02,
+ -90.0};
+
+static double t32Lats[T32_LEN+2] = { 90.0,
+ 0.87159094555866E+02, 0.83478936669319E+02, 0.79777045654826E+02, 0.76070244462545E+02,
+ 0.72361581029344E+02, 0.68652016789517E+02, 0.64941949488758E+02, 0.61231573188077E+02,
+ 0.57520993797970E+02, 0.53810274031941E+02, 0.50099453412987E+02, 0.46388558111605E+02,
+ 0.42677606172605E+02, 0.38966610469454E+02, 0.35255580461368E+02, 0.31544523284022E+02,
+ 0.27833444451993E+02, 0.24122348326088E+02, 0.20411238433568E+02, 0.16700117693843E+02,
+ 0.12988988582088E+02, 0.92778532515079E+01, 0.55667136279136E+01, 0.18555714859933E+01,
+-0.18555714859933E+01,-0.55667136279136E+01,-0.92778532515079E+01,-0.12988988582088E+02,
+-0.16700117693843E+02,-0.20411238433568E+02,-0.24122348326088E+02,-0.27833444451993E+02,
+-0.31544523284022E+02,-0.35255580461368E+02,-0.38966610469454E+02,-0.42677606172605E+02,
+-0.46388558111605E+02,-0.50099453412987E+02,-0.53810274031941E+02,-0.57520993797970E+02,
+-0.61231573188077E+02,-0.64941949488758E+02,-0.68652016789517E+02,-0.72361581029344E+02,
+-0.76070244462545E+02,-0.79777045654826E+02,-0.83478936669319E+02,-0.87159094555866E+02,
+ -90.0};
+
+static double r21Lats[R21_LEN+2] = { 90.0,
+ 0.87561335285568E+02, 0.84402246942727E+02, 0.81224502565854E+02, 0.78042543117275E+02,
+ 0.74858984933994E+02, 0.71674653274293E+02, 0.68489889517576E+02, 0.65304860195126E+02,
+ 0.62119656165245E+02, 0.58934331201119E+02, 0.55748919163754E+02, 0.52563442446061E+02,
+ 0.49377916458473E+02, 0.46192352163669E+02, 0.43006757583317E+02, 0.39821138732503E+02,
+ 0.36635500220498E+02, 0.33449845649242E+02, 0.30264177884999E+02, 0.27078499248141E+02,
+ 0.23892811648733E+02, 0.20707116685476E+02, 0.17521415719380E+02, 0.14335709929790E+02,
+ 0.11150000357943E+02, 0.79642879416817E+01, 0.47785735439230E+01, 0.15928579768305E+01,
+-0.15928579768305E+01,-0.47785735439230E+01,-0.79642879416817E+01,-0.11150000357943E+02,
+-0.14335709929790E+02,-0.17521415719380E+02,-0.20707116685476E+02,-0.23892811648733E+02,
+-0.27078499248141E+02,-0.30264177884999E+02,-0.33449845649242E+02,-0.36635500220498E+02,
+-0.39821138732503E+02,-0.43006757583317E+02,-0.46192352163669E+02,-0.49377916458473E+02,
+-0.52563442446061E+02,-0.55748919163754E+02,-0.58934331201119E+02,-0.62119656165245E+02,
+-0.65304860195126E+02,-0.68489889517576E+02,-0.71674653274293E+02,-0.74858984933994E+02,
+-0.78042543117275E+02,-0.81224502565854E+02,-0.84402246942727E+02,-0.87561335285568E+02,
+ -90.0};
+
+static double t42Lats[T42_LEN+2] = { 90.0,
+ 0.87863798839235E+02, 0.85096526988318E+02, 0.82312912947887E+02, 0.79525606572659E+02,
+ 0.76736899680368E+02, 0.73947515153990E+02, 0.71157752011587E+02, 0.68367756108313E+02,
+ 0.65577607010828E+02, 0.62787351798963E+02, 0.59997020108491E+02, 0.57206631527643E+02,
+ 0.54416199526086E+02, 0.51625733674938E+02, 0.48835240966250E+02, 0.46044726631102E+02,
+ 0.43254194665351E+02, 0.40463648178115E+02, 0.37673089629045E+02, 0.34882520993773E+02,
+ 0.32091943881744E+02, 0.29301359621763E+02, 0.26510769325211E+02, 0.23720173933535E+02,
+ 0.20929574254490E+02, 0.18138970990239E+02, 0.15348364759492E+02, 0.12557756115231E+02,
+ 0.97671455591956E+01, 0.69765335539487E+01, 0.41859205331892E+01, 0.13953069108195E+01,
+-0.13953069108195E+01,-0.41859205331892E+01,-0.69765335539487E+01,-0.97671455591956E+01,
+-0.12557756115231E+02,-0.15348364759492E+02,-0.18138970990239E+02,-0.20929574254490E+02,
+-0.23720173933535E+02,-0.26510769325211E+02,-0.29301359621763E+02,-0.32091943881744E+02,
+-0.34882520993773E+02,-0.37673089629045E+02,-0.40463648178115E+02,-0.43254194665351E+02,
+-0.46044726631102E+02,-0.48835240966250E+02,-0.51625733674938E+02,-0.54416199526086E+02,
+-0.57206631527643E+02,-0.59997020108491E+02,-0.62787351798963E+02,-0.65577607010828E+02,
+-0.68367756108313E+02,-0.71157752011587E+02,-0.73947515153990E+02,-0.76736899680368E+02,
+-0.79525606572659E+02,-0.82312912947887E+02,-0.85096526988318E+02,-0.87863798839235E+02,
+ -90.0};
+
+static double r31Lats[R31_LEN+2] = { 90.0,
+ 0.88288379267616E+02, 0.86071116222004E+02, 0.83840759055046E+02, 0.81607443388288E+02,
+ 0.79373005516595E+02, 0.77138024633268E+02, 0.74902740311571E+02, 0.72667269403298E+02,
+ 0.70431675646397E+02, 0.68195996748286E+02, 0.65960256438704E+02, 0.63724470396021E+02,
+ 0.61488649395195E+02, 0.59252801086411E+02, 0.57016931052170E+02, 0.54781043462613E+02,
+ 0.52545141496602E+02, 0.50309227620722E+02, 0.48073303779176E+02, 0.45837371526077E+02,
+ 0.43601432119569E+02, 0.41365486590024E+02, 0.39129535790308E+02, 0.36893580433377E+02,
+ 0.34657621120798E+02, 0.32421658364662E+02, 0.30185692604616E+02, 0.27949724221253E+02,
+ 0.25713753546746E+02, 0.23477780873385E+02, 0.21241806460492E+02, 0.19005830540092E+02,
+ 0.16769853321590E+02, 0.14533874995695E+02, 0.12297895737733E+02, 0.10061915710489E+02,
+ 0.78259350666721E+01, 0.55899539511030E+01, 0.33539725026723E+01, 0.11179908561455E+01,
+-0.11179908561455E+01,-0.33539725026723E+01,-0.55899539511030E+01,-0.78259350666721E+01,
+-0.10061915710489E+02,-0.12297895737733E+02,-0.14533874995695E+02,-0.16769853321590E+02,
+-0.19005830540092E+02,-0.21241806460492E+02,-0.23477780873385E+02,-0.25713753546746E+02,
+-0.27949724221253E+02,-0.30185692604616E+02,-0.32421658364662E+02,-0.34657621120798E+02,
+-0.36893580433377E+02,-0.39129535790308E+02,-0.41365486590024E+02,-0.43601432119569E+02,
+-0.45837371526077E+02,-0.48073303779176E+02,-0.50309227620722E+02,-0.52545141496602E+02,
+-0.54781043462613E+02,-0.57016931052170E+02,-0.59252801086411E+02,-0.61488649395195E+02,
+-0.63724470396021E+02,-0.65960256438704E+02,-0.68195996748286E+02,-0.70431675646397E+02,
+-0.72667269403298E+02,-0.74902740311571E+02,-0.77138024633268E+02,-0.79373005516595E+02,
+-0.81607443388288E+02,-0.83840759055046E+02,-0.86071116222004E+02,-0.88288379267616E+02,
+ -90.0};
+
+static double t63Lats[T63_LEN+2] = { 90.0,
+ 0.88572168514010E+02, 0.86722530954669E+02, 0.84861970292044E+02, 0.82998941642838E+02,
+ 0.81134976837678E+02, 0.79270559034861E+02, 0.77405888082079E+02, 0.75541061452879E+02,
+ 0.73676132313210E+02, 0.71811132114274E+02, 0.69946080646983E+02, 0.68080990985652E+02,
+ 0.66215872113999E+02, 0.64350730408872E+02, 0.62485570522036E+02, 0.60620395926826E+02,
+ 0.58755209269380E+02, 0.56890012601357E+02, 0.55024807538312E+02, 0.53159595370020E+02,
+ 0.51294377138951E+02, 0.49429153697123E+02, 0.47563925747979E+02, 0.45698693877702E+02,
+ 0.43833458578951E+02, 0.41968220269075E+02, 0.40102979304249E+02, 0.38237735990564E+02,
+ 0.36372490592812E+02, 0.34507243341501E+02, 0.32641994438518E+02, 0.30776744061723E+02,
+ 0.28911492368718E+02, 0.27046239499945E+02, 0.25180985581271E+02, 0.23315730726141E+02,
+ 0.21450475037398E+02, 0.19585218608822E+02, 0.17719961526447E+02, 0.15854703869695E+02,
+ 0.13989445712357E+02, 0.12124187123456E+02, 0.10258928168006E+02, 0.83936689076924E+01,
+ 0.65284094014800E+01, 0.46631497061779E+01, 0.27978898769568E+01, 0.93262996783805E+00,
+-0.93262996783805E+00,-0.27978898769568E+01,-0.46631497061779E+01,-0.65284094014800E+01,
+-0.83936689076924E+01,-0.10258928168006E+02,-0.12124187123456E+02,-0.13989445712357E+02,
+-0.15854703869695E+02,-0.17719961526447E+02,-0.19585218608822E+02,-0.21450475037398E+02,
+-0.23315730726141E+02,-0.25180985581271E+02,-0.27046239499945E+02,-0.28911492368718E+02,
+-0.30776744061723E+02,-0.32641994438518E+02,-0.34507243341501E+02,-0.36372490592812E+02,
+-0.38237735990564E+02,-0.40102979304249E+02,-0.41968220269075E+02,-0.43833458578951E+02,
+-0.45698693877702E+02,-0.47563925747979E+02,-0.49429153697123E+02,-0.51294377138951E+02,
+-0.53159595370020E+02,-0.55024807538312E+02,-0.56890012601357E+02,-0.58755209269380E+02,
+-0.60620395926826E+02,-0.62485570522036E+02,-0.64350730408872E+02,-0.66215872113999E+02,
+-0.68080990985652E+02,-0.69946080646983E+02,-0.71811132114274E+02,-0.73676132313210E+02,
+-0.75541061452879E+02,-0.77405888082079E+02,-0.79270559034861E+02,-0.81134976837678E+02,
+-0.82998941642838E+02,-0.84861970292044E+02,-0.86722530954669E+02,-0.88572168514010E+02,
+ -90.0};
+
+static double r40Lats[R40_LEN+2] = { 90.0,
+ 0.88655748210102E+02, 0.86914381231598E+02, 0.85162730544504E+02, 0.83408756335181E+02,
+ 0.81653900766134E+02, 0.79898618712720E+02, 0.78143098323582E+02, 0.76387431365792E+02,
+ 0.74631667892398E+02, 0.72875837512789E+02, 0.71119958858586E+02, 0.69364044237958E+02,
+ 0.67608102107902E+02, 0.65852138471109E+02, 0.64096157706139E+02, 0.62340163082069E+02,
+ 0.60584157089161E+02, 0.58828141657961E+02, 0.57072118308388E+02, 0.55316088253607E+02,
+ 0.53560052473900E+02, 0.51804011770183E+02, 0.50047966803437E+02, 0.48291918124176E+02,
+ 0.46535866194786E+02, 0.44779811406672E+02, 0.43023754093555E+02, 0.41267694541909E+02,
+ 0.39511632999215E+02, 0.37755569680566E+02, 0.35999504773979E+02, 0.34243438444712E+02,
+ 0.32487370838797E+02, 0.30731302085950E+02, 0.28975232301977E+02, 0.27219161590792E+02,
+ 0.25463090046107E+02, 0.23707017752859E+02, 0.21950944788430E+02, 0.20194871223677E+02,
+ 0.18438797123838E+02, 0.16682722549301E+02, 0.14926647556282E+02, 0.13170572197421E+02,
+ 0.11414496522311E+02, 0.96584205779655E+01, 0.79023444092484E+01, 0.61462680592605E+01,
+ 0.43901915696985E+01, 0.26341149811898E+01, 0.87803833361026E+00,-0.87803833361026E+00,
+-0.26341149811898E+01,-0.43901915696985E+01,-0.61462680592605E+01,-0.79023444092484E+01,
+-0.96584205779655E+01,-0.11414496522311E+02,-0.13170572197421E+02,-0.14926647556282E+02,
+-0.16682722549301E+02,-0.18438797123838E+02,-0.20194871223677E+02,-0.21950944788430E+02,
+-0.23707017752859E+02,-0.25463090046107E+02,-0.27219161590792E+02,-0.28975232301977E+02,
+-0.30731302085950E+02,-0.32487370838797E+02,-0.34243438444712E+02,-0.35999504773979E+02,
+-0.37755569680566E+02,-0.39511632999215E+02,-0.41267694541909E+02,-0.43023754093555E+02,
+-0.44779811406672E+02,-0.46535866194786E+02,-0.48291918124176E+02,-0.50047966803437E+02,
+-0.51804011770183E+02,-0.53560052473900E+02,-0.55316088253607E+02,-0.57072118308388E+02,
+-0.58828141657961E+02,-0.60584157089161E+02,-0.62340163082069E+02,-0.64096157706139E+02,
+-0.65852138471109E+02,-0.67608102107902E+02,-0.69364044237958E+02,-0.71119958858586E+02,
+-0.72875837512789E+02,-0.74631667892398E+02,-0.76387431365792E+02,-0.78143098323582E+02,
+-0.79898618712720E+02,-0.81653900766134E+02,-0.83408756335181E+02,-0.85162730544504E+02,
+-0.86914381231598E+02,-0.88655748210102E+02,
+ -90.0};
+
+static double t106Lats[T106_LEN+2] = { 90.0,
+ 0.89141519426470E+02, 0.88029428867955E+02, 0.86910770814124E+02, 0.85790628883637E+02,
+ 0.84669924084448E+02, 0.83548946912543E+02, 0.82427817524009E+02, 0.81306594522669E+02,
+ 0.80185309872478E+02, 0.79063982481409E+02, 0.77942624246673E+02, 0.76821243027101E+02,
+ 0.75699844222012E+02, 0.74578431663296E+02, 0.73457008145583E+02, 0.72335575754909E+02,
+ 0.71214136079887E+02, 0.70092690351624E+02, 0.68971239538936E+02, 0.67849784414670E+02,
+ 0.66728325602882E+02, 0.65606863613010E+02, 0.64485398865043E+02, 0.63363931708340E+02,
+ 0.62242462435891E+02, 0.61120991295252E+02, 0.59999518497041E+02, 0.58878044221583E+02,
+ 0.57756568624184E+02, 0.56635091839330E+02, 0.55513613984077E+02, 0.54392135160792E+02,
+ 0.53270655459398E+02, 0.52149174959221E+02, 0.51027693730508E+02, 0.49906211835711E+02,
+ 0.48784729330535E+02, 0.47663246264842E+02, 0.46541762683406E+02, 0.45420278626548E+02,
+ 0.44298794130694E+02, 0.43177309228835E+02, 0.42055823950935E+02, 0.40934338324279E+02,
+ 0.39812852373771E+02, 0.38691366122202E+02, 0.37569879590472E+02, 0.36448392797794E+02,
+ 0.35326905761872E+02, 0.34205418499049E+02, 0.33083931024446E+02, 0.31962443352088E+02,
+ 0.30840955495002E+02, 0.29719467465319E+02, 0.28597979274356E+02, 0.27476490932696E+02,
+ 0.26355002450250E+02, 0.25233513836324E+02, 0.24112025099671E+02, 0.22990536248541E+02,
+ 0.21869047290730E+02, 0.20747558233616E+02, 0.19626069084199E+02, 0.18504579849136E+02,
+ 0.17383090534771E+02, 0.16261601147162E+02, 0.15140111692111E+02, 0.14018622175186E+02,
+ 0.12897132601745E+02, 0.11775642976956E+02, 0.10654153305818E+02, 0.95326635931757E+01,
+ 0.84111738437432E+01, 0.72896840621151E+01, 0.61681942527845E+01, 0.50467044201572E+01,
+ 0.39252145685665E+01, 0.28037247022868E+01, 0.16822348255471E+01, 0.56074494254426E+00,
+-0.56074494254426E+00,-0.16822348255471E+01,-0.28037247022868E+01,-0.39252145685665E+01,
+-0.50467044201572E+01,-0.61681942527845E+01,-0.72896840621151E+01,-0.84111738437432E+01,
+-0.95326635931757E+01,-0.10654153305818E+02,-0.11775642976956E+02,-0.12897132601745E+02,
+-0.14018622175186E+02,-0.15140111692111E+02,-0.16261601147162E+02,-0.17383090534771E+02,
+-0.18504579849136E+02,-0.19626069084199E+02,-0.20747558233616E+02,-0.21869047290730E+02,
+-0.22990536248541E+02,-0.24112025099671E+02,-0.25233513836324E+02,-0.26355002450250E+02,
+-0.27476490932696E+02,-0.28597979274356E+02,-0.29719467465319E+02,-0.30840955495002E+02,
+-0.31962443352088E+02,-0.33083931024446E+02,-0.34205418499049E+02,-0.35326905761872E+02,
+-0.36448392797794E+02,-0.37569879590472E+02,-0.38691366122202E+02,-0.39812852373771E+02,
+-0.40934338324279E+02,-0.42055823950935E+02,-0.43177309228835E+02,-0.44298794130694E+02,
+-0.45420278626548E+02,-0.46541762683406E+02,-0.47663246264842E+02,-0.48784729330535E+02,
+-0.49906211835711E+02,-0.51027693730508E+02,-0.52149174959221E+02,-0.53270655459398E+02,
+-0.54392135160792E+02,-0.55513613984077E+02,-0.56635091839330E+02,-0.57756568624184E+02,
+-0.58878044221583E+02,-0.59999518497041E+02,-0.61120991295252E+02,-0.62242462435891E+02,
+-0.63363931708340E+02,-0.64485398865043E+02,-0.65606863613010E+02,-0.66728325602882E+02,
+-0.67849784414670E+02,-0.68971239538936E+02,-0.70092690351624E+02,-0.71214136079887E+02,
+-0.72335575754909E+02,-0.73457008145583E+02,-0.74578431663296E+02,-0.75699844222012E+02,
+-0.76821243027101E+02,-0.77942624246673E+02,-0.79063982481409E+02,-0.80185309872478E+02,
+-0.81306594522669E+02,-0.82427817524009E+02,-0.83548946912543E+02,-0.84669924084448E+02,
+-0.85790628883637E+02,-0.86910770814124E+02,-0.88029428867955E+02,-0.89141519426470E+02,
+ -90.0};
diff --git a/include/cdTime/grads.h b/include/cdTime/grads.h
new file mode 100644
index 0000000..9f53f91
--- /dev/null
+++ b/include/cdTime/grads.h
@@ -0,0 +1,1100 @@
+/* Copyright (c) 1988-1995 by Brian Doty
+ See file COPYRIGHT for complete rights and liability information. */
+
+/* Handling of missing data values. If SETMISS is 0, it is assumed
+ that missing data values will exactly match the value parsed from
+ the data description file (true on many machines). If SETMISS is 1,
+ a test is done for a small range (+-value/EPSILON) and if true the
+ value is set to exactly the missing data value when read. */
+
+#include <stdio.h>
+
+#define SETMISS 1
+#define EPSILON 1e5
+#define FUZZ_SCALE 1e-5
+
+/* RPTNUM: Number of garpt blocks to allocate per memory block
+ BLKNUM: Max number of memory requests
+ A max of RPTNUM*BLKNUM stations can be held per request */
+
+#define RPTNUM 200
+#define BLKNUM 500
+
+#if GRADS_CRAY == 1
+#define CPULIMSIG SIGCPULIM
+#else
+#define CPULIMSIG SIGXCPU
+#endif
+
+ /*******************\
+ * Data Structures *
+ \*******************/
+
+/* Pointer to data object */
+
+union gadata {
+ struct gagrid *pgr;
+ struct gastn *stn;
+};
+
+/* Date/time structure. */
+
+struct dt {
+ int yr;
+ int mo;
+ int dy;
+ int hr;
+ int mn;
+};
+
+/* Collection structure */
+
+struct gaclct {
+ struct gaclct *forw; /* Forward Pointer */
+ struct gastn *stn; /* Pointer to station data */
+ struct gastn *stn2; /* Pointer to station data */
+};
+
+/* info for LATS */
+
+struct galats {
+
+/*=== lats_parmtab ===*/
+ char ptname[256]; /* parameter file name */
+
+/*=== lats_create ===*/
+ int convention; /* data convention (enum) */
+ int frequency; /* data frequency (enum) e.g., hourly */
+ int calendar; /* calendar of the time model (enum) e.g., standard */
+ int deltat; /* number of time units between outputs, e.g., 12 for every 12 h */
+ char model[256]; /* model COMMENT */
+ char center[32]; /* data source which is the GRIB PROCESS ! NOT the GRIB CENTER */
+ char comment[256]; /* comment on data set which will go into the title of the .ctl file */
+ char oname[256]; /* name of the output file (dset) */
+
+/*=== lats_basetime ===*/
+ int lyr; /* lats basetime year */
+ int lmo; /* lats basetime month */
+ int lda; /* lats basetime day */
+ int lhr; /* lats basetime hour */
+
+/*=== lats_vertdim ===*/
+ char vertdimname[32]; /* name of the vertial dimension */
+ double levels[128]; /* vertical levels MAX IS 128!!!*/
+ int nlev; /* number of levels */
+
+/*=== lats_grid ===*/
+ int gridtype; /* grid type (enum), calculated in GrADS except when LATS_GAUSSIAN */
+ char gridname[32]; /* name of the vertial dimension */
+ int ilinear; /* linearity of the grid in x */
+ int jlinear; /* linearity of the grid in y */
+ int nlon; /* # of points in x */
+ int nlat; /* # of points in y */
+ float lon_1; /* starting longitide */
+ float lat_1; /* starting latitude */
+ float lon_nlon; /* ending longitude */
+ float lat_nlat; /* ending latitude */
+
+/*=== lats_var ===*/
+ char var[32]; /* variable name */
+ char var_comment[256]; /* variable name */
+ int timestat; /* variable time statistic (enum) */
+
+/*=== lats_write ===*/
+ double varlev; /* level value of the variable for lats_write*/
+
+/*--- time options ---*/
+ int time_opt; /* 0 - grid relative ; 1 - dimension environment relative ; 2 - set time using baset time ; 3 - forecast hourly */
+ int fhour; /* forecast hour if using lats forecast_hourly */
+
+/*--- internal id's to pass to the lats routines ---*/
+ int id_file;
+ int id_lev;
+ int id_grid;
+ int id_var;
+
+ int id_user_file;
+ int id_user_var;
+ int id_user_grid;
+ int id_user_lev;
+ int id_user_write;
+
+};
+
+
+/*mf 9612105 Contains global information for Mike Fiorino mf*/
+
+struct gamfcmn {
+ int cal365 ; /* 365 (no leap year) calendar */
+ int fullyear ; /* 1 - must specify full year 0 old default */
+ int warnflg; /* warning level flag for messages */
+};
+
+/* Contains information about the user interface and graphics output. */
+struct gacmn {
+
+ int pass; /* Number of passes since last clear */
+ int gpass[10]; /* Number of passes for each gx type */
+ int loopdim; /* Looping dimension */
+ int loopflg; /* Looping on or off */
+ float loopincr; /* Looping increment */
+
+ struct gafile *pfi1; /* Pointer to first gafile in chain */
+ struct gafile *pfid; /* Pointer to default gafile */
+ int fnum; /* File count */
+ int dfnum; /* Default file number */
+
+ struct gadefn *pdf1; /* Pointer to first define block */
+
+ float dmin[3],dmax[3]; /* Current absolute coordinate limits */
+ struct dt tmin,tmax;
+ int vdim[4]; /* Which dimensions vary? */
+
+ float pxsize,pysize; /* Physical page size in inches */
+ int orient; /* Page orientation */
+ int vpflag; /* If 1, virtual page being used */
+ float xsiz,xsiz1,xsiz2; /* Physical plotting size in X direction */
+ float ysiz,ysiz1,ysiz2; /* Physical plotting size in Y direction */
+ int paflg; /* User has specified plotting area */
+ float pxmin,pxmax; /* User specified plotting area */
+ float pymin,pymax;
+ float aspect; /* User specified aspect ratio */
+
+ int clab; /* control contour labels. */
+ int clskip; /* Contour label skipping */
+ char *clstr; /* Contour label template */
+ float rainmn,rainmx; /* control rainbow colors */
+ int rbflg; /* User rainbow colors specified */
+ int rbcols[100]; /* User rainbow colors */
+
+ float cmin,cmax,cint; /* User specified contour limits */
+ int cflag; /* If true, user specifies contour levels*/
+ float clevs[100]; /* User specified contour levels */
+ int ccflg; /* If true, user specifies contour colors*/
+ int ccols[100]; /* User specified contour colors */
+ int shdcls[120]; /* Shade colors after shading */
+ float shdlvs[120]; /* Shade levels */
+ int shdcnt; /* Number of shdlvs, shdcls */
+ int ccolor,cstyle; /* User contour/line appearance */
+ int cthick; /* User gx display line thickness */
+ int cmark; /* Line marker type */
+ int csmth; /* Contour smoothing on or off */
+ int cterp; /* Spline fit on or off */
+ float rmin,rmax,rint; /* Axis limits for 1-D plots */
+ float rmin2,rmax2,rint2; /* Axis limits for 1-D plots */
+ int aflag,aflag2; /* Keep 1D axis limits fixed */
+ int grflag,grstyl,grcolr; /* Grid flag, linestyle, color */
+ int dignum; /* grid value plot control (gxout=grid) */
+ float digsiz;
+ int arrflg; /* Use already set arrow scaling */
+ float arrsiz; /* Arrow size in inches */
+ int arlflg; /* Arrow label flag */
+ float arrmag; /* Vector magnitude producing arrsiz arrw*/
+ float ahdsiz; /* Arrow head size. */
+ int miconn; /* Connect line graph accross missing */
+ int strmden; /* Streamline density indicator */
+ int mdlblnk,mdldig3; /* Station model plot opts */
+
+ int fgvals[50]; /* Values for grid fill */
+ int fgcols[50];
+ int fgcnt;
+
+ int stidflg; /* Plot station ids with values */
+
+ float axmin,axmax,axint; /* Overrides for X-axis labels */
+ float aymin,aymax,ayint; /* Overrides for Y-axis labels */
+ int axflg, ayflg; /* Is override in effect for the axis? */
+ int frame; /* Display frame? */
+
+ int rotate; /* Rotate plot from default orientation */
+ int xflip, yflip; /* Flip X or Y axes */
+ int zlog; /* Z coordinate in log scale */
+
+ int mproj; /* Map projection -- used for X,Y plot */
+ /* only. 0 = no map. */
+ int mpdraw; /* Draw map outline - 0=no */
+ float mpvals[10]; /* Map projection option values. */
+ int mpflg; /* Map projection option values are set. */
+ char *mpdset[8]; /* Map data set names. */
+ int mpcols[256]; /* Map Color array */
+ int mpstls[256]; /* Map line styles array */
+ int mpthks[256]; /* Map line widths array */
+ int mapcol,mapstl,mapthk; /* Default map color, style, thickness */
+
+ int gout0; /* Graphics output type for stat. */
+ int gout1; /* Graphics output type for 1-D. */
+ int gout2a; /* Graphics output type for 2-D. */
+ int gout2b; /* Graphics output type for 2-D. */
+ int goutstn; /* Graphics output type for stns */
+
+ int blkflg; /* Leave certain values black when shadng*/
+ float blkmin, blkmax; /* Black range */
+
+ int reccol,recthk; /* Draw Rectangle color, brdr thickness */
+ int lincol,linstl,linthk; /* Draw line color, style, thickness */
+ int mcolor; /* auto color (orange or grey) */
+ int strcol,strthk,strjst; /* Draw string color, thckns, justifictn */
+ float strrot; /* Draw string rotation */
+ float strhsz,strvsz; /* Draw string hor. size, vert. size */
+ int anncol,annthk; /* Draw title color, thickness */
+ int grflg; /* Grey Scale flag */
+ int devbck; /* Device background */
+ int xlcol,xlthck,ylcol,ylthck,clcol,clthck; /* color, thickness */
+ int xlside,ylside,ylpflg;
+ float xlsiz,ylsiz,clsiz,xlpos,ylpos,yllow; /* Axis lable size */
+ float xlevs[50],ylevs[50]; /* User specified x/y axis labels */
+ int xlflg,ylflg; /* Number of user specified labels */
+ int xtick,ytick; /* Number of extra tick marks */
+ float xlint,ylint; /* User specified label increment */
+ char *xlstr, *ylstr; /* user substitution string for labels */
+ int xlab,ylab; /* Axis label options */
+ char *xlabs, *ylabs; /* User specifies all labels */
+ int ixlabs, iylabs; /* Count of user labels */
+ int lfc1,lfc2; /* Linefill colors */
+ int wxcols[5]; /* wx symbol colors */
+ int wxopt; /* wx options */
+ int tser; /* station time series type */
+
+ int bargap; /* Bar Gap in percent */
+ int barolin; /* Bar outline flag */
+ float barbase; /* Bar Base Value */
+ int barflg; /* Bar flag: 1, use base value */
+ /* 0, draw from plot base */
+ /* -1, draw from plot top */
+
+ int btnfc,btnbc,btnoc,btnoc2; /* Current button attributes */
+ int btnftc,btnbtc,btnotc,btnotc2;
+ int btnthk;
+
+ int drvals[15]; /* Attributes for drop menus */
+
+ FILE *ffile; /* grads.fwrite file handle */
+ char *fwname; /* fwrite file name */
+
+ int grdsflg; /* Indicate whether to put grads atrib. */
+
+ int timelabflg; /* Indicate whether to put cur time atrib. */
+
+ int dbflg; /* Double buffer mode flag */
+
+ int batflg; /* Batch mode */
+
+ int numgrd,relnum; /* Number of data objects held */
+ int type[16]; /* Data type of each data object */
+ union gadata result[16]; /* Pointers to held data objects */
+ struct gaclct *clct[32]; /* Anchor for collection */
+ int clctnm[32]; /* Number of items collected */
+ int clcttp[32]; /* Varying dimension of collection */
+
+ int lastgx; /* Last gx plotted */
+ int xdim, ydim; /* Which dimensions on X and Y axis */
+ /* Grid-to-world conversion info follows */
+
+ float (*xgr2ab) (float *, float);
+ float (*ygr2ab) (float *, float);
+ float (*xab2gr) (float *, float);
+ float (*yab2gr) (float *, float);
+ float *xgrval;
+ float *ygrval;
+ float *xabval;
+ float *yabval;
+
+ int impflg; /* Implied run flag */
+ char *impnam; /* Implided run script name */
+
+ int impcmd; /* Implicit run */
+
+ int sig; /* User has signalled */
+
+ int ptflg; /* Pattern fill flag */
+ int ptopt; /* Pattern option: */
+ /* 0, open */
+ /* 1, solid */
+ /* 2, dot */
+ /* 3, line */
+ int ptden; /* Dot or line pattern density */
+ int ptang; /* Line pattern angle */
+
+ struct galats glats ; /* LATS option struct */
+
+};
+
+
+
+/* GA status structure. Contains necessary info about the scaling
+ and file structure in force. */
+
+struct gastat {
+
+ struct gafile *pfi1; /* Pointer to first gafile in chain */
+
+ struct gafile *pfid; /* Pointer to default gafile */
+
+ int fnum; /* Default file number */
+
+ struct gadefn *pdf1; /* Pointer to first define block */
+
+ struct gaclct **pclct; /* Pointer to the collection pointers */
+
+ union gadata result; /* Result goes here */
+
+ int type; /* Result type (grid or stn) */
+
+ int idim,jdim; /* Varying dimensions */
+
+ float dmin[3],dmax[3]; /* Range of absolute dimensions */
+ struct dt tmin,tmax;
+
+};
+
+/* Description of a data file. */
+
+/* This is to define the pointer added at the end of the gafile structure */
+/* -hoop, 95/07/10 and 95/11/10 */
+#if USESDF == 1
+#include "gasdf.h"
+#endif
+
+struct gafile {
+
+ struct gafile *pforw; /* Forward pointer to next gafile block.
+ List is anchored within gastat. */
+
+ char name[256]; /* File name. */
+
+ char *tempname; /* File name of open file (different with templates) */
+
+ char dnam[256]; /* Descriptor file name */
+
+ char *mnam; /* Map(index) file name */
+
+ FILE *infile; /* File pointer. */
+
+ int type; /* Type of file: 1 = grid
+ 2 = simple station
+ 3 = mapped station
+ 4 = defined grid */
+
+ char title[80]; /* Title -- describes the file. */
+ float undef; /* Global undefined value for this file */
+ float ulow,uhi; /* Undefined limits for SETMISS test */
+
+ float *rbuf; /* Buffer for file I/O equal in length
+ to one grid row in the file, or equal
+ in length to the size needed to hold
+ the largest station report */
+ char *pbuf; /* Same as rbuf, for unpacking */
+ char *bbuf; /* Same as rbuf, for bit map I/O */
+
+ int bswap; /* Byte swapping needed */
+
+ int mtype; /* Stn map file type */
+ int *tstrt; /* Pointer to list length dnum[3] of
+ start points of times in the file */
+ int *tcnt; /* Count of stns for assctd time */
+ int stcnt; /* Count of mapped stids when stn data
+ and map file is type stidmap. */
+ int stpos; /* Position in map file of start of
+ stid info for map file type stidmap. */
+ FILE *mfile; /* File pointer to stidmap file */
+
+ int dnum[4]; /* Dimension sizes for this file. */
+
+ int tlpflg; /* Circular file flag */
+
+ int tlpst; /* Start time offset in circular file */
+
+ int vnum; /* Number of variables. */
+
+ int ivnum; /* Number of level independent variables
+ for station data file */
+
+ int lvnum; /* Number of level dependent variables
+ for station data file */
+
+ struct gavar *pvar1; /* Pointer to an array of structures.
+ Each structure in the array has info
+ about the specific variable. */
+
+ int gsiz; /* Number of elements in a grid (x*y) */
+ /* This is for actual grid on disk,
+ not psuedo grid (when pp in force) */
+
+ int tsiz; /* Number of elements in an entire time
+ group (all variables at all levels
+ for one time). */
+ int trecs; /* Number of records (XY grids) per time
+ group. */
+ int fhdr; /* Number of bytes to ignore at file head*/
+
+ int wrap; /* The grid globally 'wraps' in X */
+
+ int seqflg, yrflg, zrflg; /* Format flags */
+
+ int ppflag; /* Pre-projection type.
+ 0 = none
+ 1 = polar stereo
+ 2 = lambert conformal */
+
+ int ppwrot; /* Pre-projection wind rotation flag */
+
+ int ppisiz, ppjsiz; /* Actual size of preprojected grid */
+
+ float ppvals[20]; /* Projection constants for pre-projected
+ grids. Values depend on projection. */
+
+ int *ppi[8]; /* Pointers to offsets for pre-projected
+ grid interpolation */
+
+ float *ppf[8]; /* Pointers to interpolation constants
+ for pre-projected grids */
+
+ float *ppw; /* Pointer to wind rotation array */
+
+ float (*gr2ab[3]) (float *, float);
+ /* Addresses of routines to do conversion
+ from grid coordinates to absolute
+ coordinates for X, Y, Z. All Date/time
+ conversions handled by gr2t. */
+
+ float (*ab2gr[3]) (float *, float);
+ /* Addresses of routines to do conversion
+ from absolute coordinates to grid
+ coordinates for X,Y,Z. All date/time
+ conversions handled by t2gr. */
+
+ float *grvals[4]; /* Pointers to conversion information for
+ grid-to-absolute conversion routines. */
+
+ float *abvals[4]; /* Pointers to conversion information for
+ absolute-to-grid conversion routines. */
+
+ int linear[4]; /* Indicates if a dimension has a linear
+ grid/absolute coord transformation
+ (Time coordinate always linear). */
+
+ int dimoff[4]; /* Dimension offsets for defined grids */
+ int climo; /* Climatological Flag (defined grids) */
+ int cysiz; /* Cycle size for climo grids */
+
+ int idxflg; /* File records are indexed */
+ int grbgrd; /* GRIB Grid type */
+ struct gaindx *pindx; /* Index Strucure if indexed file */
+
+ int tmplat; /* File name template */
+ int *fnums; /* File number for each time */
+ int fnumc; /* Current file number that is open */
+
+ int errcnt; /* Current error count */
+ int errflg; /* Current error flag */
+
+/*mf mf*/
+ int xyhdr; /* Number of bytes to ignore at head of xy grids*/
+ int thdr; /* Number of bytes to ignore at head of time chunk*/
+ int calendar; /* Support for 365-day calendars */
+ int cray_ieee; /* Support 32-bit IEEE data on cray */
+/*mf mf*/
+
+
+/* Use of this with the ifdef has implications for checkpoint/restart, */
+/* as it changes the size of the gafile structure. -hoop 95/07/10 */
+#if USESDF == 1
+ IO_STD *sdf_ptr ; /* Pointer to SDF file structure */
+#endif
+
+};
+
+
+/* Structure that describes a grid (requestor or descriptor block). */
+
+struct gagrid {
+
+ float *grid; /* Address of the grid. */
+
+ struct gafile *pfile; /* Address of the associated gafile
+ structure to get the data from
+ (requestor block only) */
+
+ float undef; /* Undefined value for this grid. */
+
+ float rmin,rmax; /* Minimum/Maximum grid value
+ (rmin is set to the grid value when
+ isiz=jsiz=1. *grid points to here.) */
+
+ int isiz,jsiz; /* isiz = number of elements per row.
+ jsiz = number of rows. */
+
+ int idim,jdim; /* Dimension of rows and columns.
+ -1 = This dimension does not vary
+ 1 = X dimension (usually longitude)
+ 2 = Y dimension (usually lattitude)
+ 3 = Z dimension (usually pressure)
+ 4 = Time
+
+ If both dimensions are -1, then the
+ grid has one value, which will be
+ placed in rmin. */
+
+ int iwrld, jwrld; /* World coordinates valid? */
+
+ int dimmin[4],dimmax[4]; /* Dimension limits for each dimension
+ (X,Y,Z,T) in grid units. */
+
+ struct gavar *pvar; /* Pointer to the structure with info
+ on this particular variable. If
+ NULL, this grid is the result of
+ an expression evaluation where the
+ variable type is unkown. */
+
+ char *exprsn; /* If grid is a 'final' result, this
+ will point to a character string that
+ contains the original expression. */
+
+ int alocf; /* Scaling info allocated for us only */
+
+ float (*igrab) (float *, float);
+ float (*jgrab) (float *, float);
+ /* Addresses of routines to perform
+ grid-to-absolute coordinate
+ transforms for this grid's i and j
+ dimensions (unless i or j = 3). */
+
+ float (*iabgr) (float *, float);
+ float (*jabgr) (float *, float);
+ /* Absolute to grid conversion routines */
+
+ float *ivals, *jvals; /* Pointers to conversion info for the
+ grid to abs conversion routines */
+ float *iavals, *javals; /* Conversion info for abs to grid */
+
+ int ilinr,jlinr; /* Indicates if linear transformation */
+
+
+};
+
+/* Structure that describes a report header in a stn file */
+
+struct rpthdr {
+ char id[8]; /* Character station id */
+ float lat; /* Latitude of report */
+ float lon; /* Longitude of report */
+ float t; /* Time in relative grid units */
+ int nlev; /* Number of levels following */
+ int flag; /* Level independent var set flag */
+};
+
+/* Structure that describes a stid info block within a stidmap file */
+
+struct stninf {
+ char stid[8];
+ int offset;
+ int rcnt;
+};
+
+/* Structure that describes a single report */
+
+struct garpt {
+
+ struct garpt *rpt; /* Address of next report */
+
+ char stid[8]; /* Station id */
+
+ float lat,lon,lev,tim; /* Location of station */
+
+ int work; /* Work area */
+
+ float val; /* Value of variable */
+
+};
+
+/* Structure that describes a collection of station reports. */
+
+struct gastn {
+
+ struct garpt *rpt; /* Address of start of link list */
+
+ int rnum; /* Number of reports. */
+
+ struct garpt *blks[BLKNUM]; /* ptrs to memory holding rpts */
+
+ struct gafile *pfi; /* Address of the associated gafile
+ structure to get the data from
+ (requestor block only) */
+
+ float undef; /* Undefined value for this data. */
+
+ int idim,jdim; /* Varying dimensions for this data
+ -1 = This dimension does not vary
+ 1 = X dimension (longitude)
+ 2 = Y dimension (lattitude)
+ 3 = Z dimension (pressure)
+ 4 = Time */
+
+ float dmin[3],dmax[3]; /* Dimension limits for each dimension
+ (X,Y,Z) in world coords.
+ Non-varying dimensions can have
+ limits in this structure. */
+
+ int rflag; /* Get stations within specified radius in
+ degrees of fixed lat and lon */
+ float radius; /* Radius */
+
+ int sflag; /* Get specific station */
+ char stid[8]; /* Station id to get */
+
+ int tmin,tmax; /* Grid limits of time */
+
+ float *tvals; /* Pointer to conversion info for the
+ time conversion routines. */
+
+ struct gavar *pvar; /* Pointer to the structure with info
+ on this particular variable. If
+ NULL, this grid is the result of
+ an expression evaluation where the
+ variable type is unkown. */
+
+ struct garpt **prev; /* Used for allocating rpt structures */
+ struct garpt *crpt;
+ int rptcnt,blkcnt;
+
+};
+
+/* Structure that describes a variable in a file. These structures
+ are built in arrays that are hung off of gafile structures. */
+
+
+struct gavar {
+
+ char varnm[128]; /* Variable name. */
+
+ char abbrv[16]; /* Variable abbreviation. */
+
+ int units[4]; /* Units indicator. */
+
+ int offset; /* Offset in grid elements of the start
+ of this variable within a time group
+ within this file. */
+
+ int recoff; /* Record (XY grid) offset of the start
+ of this variable within a time group */
+
+ int levels; /* Number of levels for this variable.
+ 0 is special and indiates one grid is
+ available for the surface only. */
+/*mf
+
+ new variable attribute to handles:
+
+ dfrm:
+
+ 1-byte
+ int dat
+
+ var_t: variable t transform
+ var_z: variable z transform
+ y_x : x-y transform
+
+mf*/
+
+ int dfrm; /* format type indicator
+ 1 - unsigned char
+ 4 - int
+ */
+
+ int var_t ;
+ int var_z ;
+ int y_x ;
+
+};
+
+/* Structure that describes a function call. */
+
+struct gafunc {
+
+ int argnum; /* Number of arguments found by fncprs */
+
+ char *argpnt[20]; /* Pointers to the argument strings */
+
+ char buff[1000]; /* Argument string buffer */
+
+};
+
+/* Structure that describes a user defined function */
+
+struct gaufb {
+ struct gaufb *ufb; /* Forward pointer */
+ char name[8]; /* Function name */
+ int alo,ahi; /* Limits on number of args */
+ int atype[8]; /* Types of args. 0=expr,1=float,2=int,3=char */
+ int sflg; /* Sequential or direct */
+ char *fname; /* Name of user executable */
+ char *oname; /* File name for data transfer to user */
+ char *iname; /* File name for data transfer from user */
+};
+
+/* Structure that describes a defined grid */
+
+struct gadefn {
+
+ struct gadefn *pforw; /* Linked list pointer */
+
+ struct gafile *pfi; /* File Structure containing the data */
+
+ char abbrv[20]; /* Abbreviation assigned to this */
+
+};
+
+/* Stack to evaluate the expression. The stack consists of an
+ array of structures. */
+
+struct smem {
+ int type; /* Entry type: -2 stn,-1 grid,1=op,2='(',3=')' */
+ union sobj {
+ int op; /* Operator: 0=*, 1=/, 2=+ */
+ struct gagrid *pgr; /* Operand (grid or stn) */
+ struct gastn *stn;
+ } obj;
+};
+
+/* Index structure, for when the records in a data file are indexed.
+ The indexing file will contain this structure at the front, followed
+ by the specified number of header and indexing values. These
+ header and indexing values are file format specific. */
+
+struct gaindx {
+ int type; /* Indexing file type */
+ int hinum; /* Number of ints in header */
+ int hfnum; /* Number of floats in header */
+ int intnum; /* Number of index ints (long) */
+ int fltnum; /* Number of index floats */
+ int *hipnt; /* Pointer to header int values */
+ float *hfpnt; /* Pointer to header float values */
+ int *intpnt; /* Pointer to int index values */
+ float *fltpnt; /* Pointer to float index values */
+} ;
+
+
+ /***********************\
+ * Function Prototypes *
+ \***********************/
+
+/* Functions in GRADS.C */
+
+void gasig (int);
+int gaqsig (void);
+
+/* Functions in GAUSER:
+ gacmd: Process a user command
+ gacln: Reset variables
+ gaenab: Process an enable command
+ gadraw: Process a draw command
+ gadef: Process a define command
+ gaudef: Process undefine command
+ gamodf: Modify defined grid
+ gaqury: Process a query command
+ gahelp: Process a help command
+ gaset: Process the SET command
+ gadspl: Process a display command
+ gapars: Parse a compound expression for gadspl
+ gagrel: Release all held grids
+ gaopen: Open a data file from a descriptor file
+ cleanup: Clean up an input record
+ gaprnt: Process output messages
+ gagsdo: Execute command for a script
+ getpst: Allocate and initialize a gastat block */
+
+void gainit (void);
+
+int gacmd (char *, struct gacmn *, int);
+void gacln (struct gacmn *,int);
+int gaenab (char *, struct gacmn *);
+int gadraw (char *, struct gacmn *);
+int gardrw (char *, struct gacmn *);
+int gaexec (char *, struct gacmn *);
+char *gagsdo (char *, int *);
+int gadef (char *, struct gacmn *, int);
+int gaudef (char *, struct gacmn *);
+int gamodf (char *, struct gacmn *);
+int gaqdef (char *, struct gacmn *, int);
+int gaqury (char *, char *, struct gacmn *);
+int gahelp (char *, struct gacmn *);
+int gaset (char *, char *, struct gacmn *);
+int gacoll (char *, struct gacmn *);
+int gadspl (char *, struct gacmn *);
+int gaspcl (char *, struct gacmn *);
+int gapars (char *, struct gastat *, struct gacmn *) ;
+void gagrel (struct gacmn *);
+int gaopen (char *, struct gacmn *);
+void cleanup (char *);
+struct gastat *getpst (struct gacmn *);
+void gaprnt (int, char *);
+
+int gaddes (char *, struct gafile *, int);
+int deflin (char *, struct gafile *, int, int);
+int deflev (char *, char *, struct gafile *, int);
+struct gafile *getpfi (void);
+
+/* Functions in GAEXPR:
+ gaexpr: Evaluate an expression by creating a stack
+ eval: Process the expression stack
+ gaoper: Perforam operation between two operands
+ gagrop: Perform a grid operation
+ gastop: Perform a station operation
+ gascop: Perform an op between a constant and stations
+ gagrvl: Put a constant in grid format
+ varprs: Parse a variable in the expression
+ getdfn: Search defined grid chain for a predifined grid
+ gagchk: Check validity of operation between two grids
+ stnvar: Handle specialized parsing of stn variable */
+
+int gaexpr (char *, struct gastat *) ;
+int eval (int, struct smem *, int *);
+int gaoper (struct smem *, int, int, int, int);
+struct gagrid *gagrop (struct gagrid *, struct gagrid *, int, int);
+struct gastn *gastop (struct gastn *, struct gastn *, int, int);
+struct gastn *gascop (struct gastn *, float, int, int);
+struct gagrid *gagrvl (float);
+char *varprs (char *, struct gastat *) ;
+int gagchk (struct gagrid *, struct gagrid *, int);
+struct gafile *getdfn (char *, struct gastat *);
+char *stnvar (char *, char *, struct gafile *, struct gavar *,
+ struct gastat *);
+
+/* Functions in GAFUNC:
+ rtnprs: Parse and execute a function call
+ gafopr: Perform opration for two-op function call
+ gafdef: Read user function definition table
+ */
+
+char *rtnprs (char *, char *, struct gastat *) ;
+int gafopr (struct gastat *, struct gastat *, int );
+void gafdef (void);
+
+/* Functions in GAIO:
+ gaggrd: Get a grid from a data file
+ gagrow: Get a row of data, possibly wrapped, from the file
+ gafcyx: Calculate file position of an item of data with x-y transposed
+ gafcor: Calculate file position of an item of data
+ garrow: Get an item or items from the data file
+ gagstn: Get a collection of stations
+ garead:
+ gardyx: garead for x-y transposed
+ gaglvs: Get appropriate var and levs from rpt
+ gaarpt: Allocate report block
+ gasstn: Seek to location in station file
+ garstn: Read station data
+ gacstn: Cache a station report
+ gagdef: Get grid from defined variable
+ clicyc: Adjust for cyclic climatological defined variable
+ gagpre: Predefined variable access */
+
+int gaggrd (struct gagrid *);
+int gagrow (float *, int *);
+int gafcor (int, int, int, int);
+int gafcyx (int, int, int, int);
+int garrow (int, int, int, int, int, float *);
+int garead (int, int, float *);
+int gardyx (int, int, float *);
+int gagstn (struct gastn *);
+int gaglvs (int, struct rpthdr *, struct gastn *);
+struct garpt *gaarpt (struct gastn *);
+int gasstn (int);
+int garstn (int, char *, int);
+void gacstn (char *, char *, int, int);
+void gagcst (int, char *);
+int gagdef (void);
+void clicyc(int *);
+int gagpre (void);
+int gairow (int, int, int, int, int, int, float *);
+int gaird (int, int, int, int, int, int);
+int gaprow (int, int, int, int, int, int, float *);
+int gaopfn (int,int *);
+int gappcn (struct gafile *, int, int);
+void w3fb04 (float, float, float, float, float *, float *);
+void ll2lc (float *, float, float, float *, float *);
+void gaiomg (void);
+
+/* Functions in GAGX:
+ gagx: Initialize graphics interface
+ gaplot: Generalized graphics output routine
+ gas1d: Set up scaling for a 1-D grid
+ gas2d: Set up scaling for a 2-D grid
+ gagrph: Plot line graph
+ gacntr: Plot contour plot
+ gastrm: Plot streamline plot
+ gafgrd: Fill grid boxes
+ gashad: Plot shaded plot
+ gavect: Plot vector feild
+ gascat: Plot scatter plot from two grids
+ gaarrw: Plot individual arrow
+ gaplvl: Plot grid values
+ gawmap: Plot appropriate map
+ gacsel: Select a contour interval
+ gaaxis: Generate proper axis labels for axes
+ galnch: Convert a longitude value to character form
+ galtch: Convert a latitude value to character form
+ gaconv: Perform grid level scaling
+ gatinc: Get date/time increment for time axis
+ gasfil: Shade fill a grid sqaure
+ trfill: Fill half a grid square (triangle)
+ gagfil: Fill grids with shaded ranges
+ */
+void gagx (struct gacmn *);
+void gaplot (struct gacmn *);
+void gas1d (struct gacmn *, float, float, int, int, struct gagrid *,
+ struct gastn *);
+void gas2d (struct gacmn *, struct gagrid *, int);
+void gagrph (struct gacmn *,int);
+void gastts (struct gacmn *);
+void galfil (struct gacmn *);
+void lfint (float, float, float, float, float *, float *);
+void lfout (float *, float *, float *, float *, int, int);
+void gacntr (struct gacmn *, int);
+void gastrm (struct gacmn *);
+void gashad (struct gacmn *);
+void gavect (struct gacmn *, int);
+void gascat (struct gacmn *);
+void gafgrd (struct gacmn *);
+void gafwrt (struct gacmn *);
+int galats (struct gacmn *, int, int); /*mf --- GrADS-lats interface mf*/
+void gaarrw (float, float, float, float, float);
+void gaplvl (struct gacmn *);
+void gamscl (struct gacmn *);
+void gawmap (struct gacmn *, int);
+void gacsel (float, float, float *, float *, float *);
+void gaaxis (int, struct gacmn *, int);
+int galnch (float, char *);
+int galtch (float, char *);
+void gaconv (float, float, float *, float *);
+void gagexp (float *, int, int, float *, int, int, float);
+void gaglin (float *, int, int, float *, int, int, float);
+struct gagrid *gaflip (struct gagrid *, struct gacmn *);
+int gatinc (struct gacmn *, struct dt *, struct dt *);
+void gasfil (int, int, float, float, float, float, float, float, float, float);
+void trfill (float, float, float, float, float, float, float, float,
+ float, int, int);
+void gafstn (struct gacmn *);
+void gapstn (struct gacmn *);
+void gawsym (struct gacmn *);
+void gabarb (float, float, float, float, float, float, float, int);
+void gapmdl (struct gacmn *);
+void gasmdl (struct gacmn *, struct garpt *, float *, float *);
+float wndexit (float, float, float, float, float, float *,
+ float *, float *, float *);
+void gapprf (struct gacmn *);
+void gatser (struct gacmn *);
+void gampax (struct gacmn *);
+void wxsym (int, float, float, float, int, int *);
+void wxprim (int, float, float, float);
+void gagsav (int, struct gacmn *, struct gagrid *);
+void galnx (float, float, float *, float *);
+void galny (float, float, float *, float *);
+void gaalnx (float, float, float *, float *);
+void gaalny (float, float, float *, float *);
+void gagfil ( float *, int, int, float *, int *, int, float);
+void gafram (struct gacmn *);
+void gaaxpl (struct gacmn *, int, int);
+void gaselc (struct gacmn *, float, float);
+int gashdc (struct gacmn *, float);
+
+/* Functions in GAUTIL:
+ nxtcmd: Get next command from the user
+ timadd: Add an increment to a time
+ timsub: Subtract an increment from a time
+ t2gr: Convert an absolute time to a grid value
+ gr2t: Convert a grid value to an absolute time
+ timdif: Calculate difference between two times
+ qleap: Determine if a year is a leap year
+ adtprs: Parse an absolute date/time expression
+ rdtprs: Parse a relative date/time expression
+ gaedit: Convert from float to character
+ cmpwrd: Compare two character strings
+ nxtwrd: Point to the next blank delimited word in a string
+ liconv: Linear conversion routine
+ gr2lev: Discrete level scaling routine
+ lev2gr: Discrete level scaling routine
+ intprs: Parse an integer expression
+ valprs: Parse a floating number expression
+ dimprs: Parse a dimension expression
+ lowcas: Convert a string to lower case
+ uppcas: Convert a string to upper case
+ getstr: Move part of a string to another string
+ getwrd: Get next word in a string as a string
+ gamnmx: Get minimum and maximum grid value
+ garemb: Remove blanks from and terminate a string
+ gagaus: Set up scaling for gaussian grid (R40)
+ gags30: Set up scaling for gaussian grid (R30)
+ gags20: Set up scaling for gaussian grid (R20)
+ gags15: Set up scaling for Ocean Grid (MOM32)
+ gamo32: Set up scaling for gaussian grid (R15)
+ gat2ch: Date/Time to character form
+ cmpch: Compare two strings of specified length
+ gafree: Free stuff hung off pst block
+ gagfre: Free gagrid block and associated data
+ gasfre: Free gastn block and associated data
+ gagbb: Unpack bit value
+ gagby: Unpack byte value
+ gabswp: Byte swap data values
+ gahswp: Byte swap report header
+ flt2ibm: convert float to ibm float (ebisuzaki)
+ ibm2flt: convert ibm float to float (ebisuzaki)
+ */
+
+int nxtcmd (char *, char *);
+void timadd (struct dt *, struct dt *);
+void timsub (struct dt *, struct dt *);
+float t2gr (float *, struct dt *);
+void gr2t (float *, float, struct dt *);
+int timdif (struct dt *, struct dt *);
+int qleap (int);
+char *adtprs (char *, struct dt *, struct dt *);
+char *rdtprs (char *, struct dt *);
+int gaedit (float, char *, int);
+int cmpwrd (char *, char *);
+char *nxtwrd (char *);
+float liconv (float *, float);
+float gr2lev (float *, float);
+float lev2gr (float *, float);
+char *intprs (char *, int *);
+char *valprs (char *, float *);
+char *dimprs (char *, struct gastat *, struct gafile *,
+ int *, float *, int, int *);
+void lowcas (char *);
+void uppcas (char *);
+void getstr (char *, char *, int);
+void getwrd (char *, char *, int);
+void gamnmx (struct gagrid *);
+int garemb (char *);
+float *gagaus(int,int);
+float *gags30(int,int);
+float *gags20(int,int);
+float *gags15(int,int);
+float *gamo32(int,int);
+int gat2ch (struct dt *, int, char *);
+int cmpch (char *, char *, int);
+void gafree (struct gastat *);
+void gagfre (struct gagrid *);
+void gasfre (struct gastn *);
+void fnmexp (char *, char *, char *);
+int gagbb (char *, int, int);
+int gagby (char *, int, int);
+char *gafndt (char *, struct dt *, struct dt *, float *);
+void gabswp (float *, int);
+void gahswp (struct rpthdr *);
+int dayweek (struct dt *);
+
+/*mf -- Wesley Ebisuzaki routines -- mf*/
+
+int flt2ibm(float x, unsigned char *ibm);
+float ibm2flt(unsigned char *ibm);
+float ieee2flt(unsigned char *);
+int flt2ieee(float , unsigned char *);
+int be_int2int(unsigned char *) ;
+
+
+
+/* Functions in GASRCP:
+ gsfile: run a script file used in gauser.c
+*/
+
+char *gsfile (char *, int *, int);
diff --git a/include/cdTime/gx.h b/include/cdTime/gx.h
new file mode 100644
index 0000000..a1670db
--- /dev/null
+++ b/include/cdTime/gx.h
@@ -0,0 +1,442 @@
+
+/* Copyright (c) 1988,1989,1990,1991 by Brian Doty
+ See file COPYRIGHT for complete rights and liability information. */
+
+void *galloc(int,char *);
+void gree();
+void glook();
+
+/* Installation options for the GX package. */
+
+/* HBUFSZ is the size of the metafile output buffer in
+ number of short integers. The metafile buffer should be as
+ large as is convenient for the target system. Frames larger
+ than the buffer will get bufferred into the meta file on disk,
+ when BUFOPT is 1. Otherwise multiple buffers of size HBUFSZ
+ will be allocated as needed. */
+
+#define HBUFSZ 100000L
+#define BUFOPT 0
+
+/*------------------------------------------------------------------------------
+ New projections: Mollweide Projection (mollweide)
+ Orthographic Projection (orthogr)
+
+ Changes in GrADS C source code files:
+ gxwmap.c
+ gagx.c
+ gauser.c
+ gx.h
+ DKRZ
+ 10.08.95 Karin Meier (karin.meier at dkrz.de)
+
+------------------------------------------------------------------------------*/
+
+#define pi 3.14159265358979
+static float lomin, lomax, lamin, lamax;
+
+
+/* Default directory containing the stroke and map data sets.
+ User can override this default via setenv GADDIR */
+
+static char *datad = "/usr/local/lib/grads";
+
+/* Option flag. If 0, map data set is only read once into a
+ dynamically allocated memory area. The memory is held onto
+ for the next call (about 35K). If 1, the memory is allocated for
+ each call and the map data set is read each time. */
+/* Lowres map only */
+
+#define MAPOPT 0
+
+/* Spacing to use for shading to get a 'solid' fill when drawing
+ lines side by side at lineweight 3. */
+
+#define SDIFF 0.005
+
+/* Structure for setting up map projections. Used to call
+ map projection routines. */
+
+struct mapprj {
+ float lnmn,lnmx,ltmn,ltmx; /* Lat,lon limits for projections */
+ float lnref; /* Reference longitude */
+ float ltref1,ltref2; /* Reference latitudes */
+ float xmn,xmx,ymn,ymx; /* Put map in this page area */
+ float axmn,axmx,aymn,aymx; /* Actual page area used by proj. */
+};
+
+/* Structure for holding info on displayed widgets. */
+
+struct gobj {
+ int type; /* Basic type of object. -1 - end of list;
+ 0 - none; 1 - btn; 2 - rbb; 3 = popm */
+ int i1,i2,j1,j2; /* Extent of object */
+ int mb; /* Mouse button that invokes object */
+ union tobj {
+ struct gbtn *btn; /* Pointer to button struct */
+ struct grbb *rbb; /* Pointer to rubber-band struct */
+ struct gdmu *dmu; /* Pointer to drop menu struct */
+ } iob;
+};
+
+/* Structure for holding information about GrADS button widgets */
+/* Also used for popmenus, which display on the screen the same
+ as buttons */
+
+struct gbtn {
+ int num; /* Button number (-1, unset) */
+ float x,y,w,h; /* Button location, size */
+ int ilo,ihi,jlo,jhi;
+ int fc,bc,oc1,oc2,ftc,btc,otc1,otc2; /* Colors */
+ int thk; /* Thickness of outline */
+ int state; /* Toggled or not? */
+ int len; /* Length of string */
+ char *ch; /* String content of btn */
+};
+
+/* Structure holds info on rubber-band regions */
+
+struct grbb {
+ int num; /* Region number (-1, unset) */
+ int mb; /* Mouse button specific */
+ float xlo,xhi,ylo,yhi; /* Rubber band region */
+ int type; /* 0 for box, 1 for line */
+};
+
+/* Structure for info on drop menus */
+
+struct gdmu {
+ int num; /* Menu number */
+ int casc; /* Anchored? */
+ float x,y,w,h; /* Header button loc,size */
+ int ilo,ihi,jlo,jhi;
+ int fc,bc,oc1,oc2; /* Colors of base */
+ int tfc,tbc,toc1,toc2; /* Colors of selected base */
+ int bfc,bbc,boc1,boc2; /* Colors of box */
+ int soc1,soc2; /* Colors of selected item */
+ int thk; /* Thickness of outlines */
+ int len; /* Length of string */
+ char *ch; /* String content of menu */
+};
+
+
+/* GrADS event queue. This queue is built as the mouse button
+ is clicked, and is cleared by a GrADS clear event. Events
+ are removed from the queue via the 'q pos' command. */
+
+struct gevent {
+ struct gevent *forw; /* Forward pointer */
+ float x, y; /* X and Y position of cursor */
+ int mbtn; /* Mouse button pressed */
+ int type; /* Type of event */
+ int info[10]; /* Integer info about event */
+ float rinfo[4]; /* Floating point info about event */
+};
+
+/* Structure for passing information on map plotting
+ options */
+
+struct mapopt {
+ int dcol,dstl,dthk; /* Default color, style, thickness */
+ int *mcol,*mstl,*mthk; /* Arrays of map line attributes */
+ float lnmin,lnmax,ltmin,ltmax; /* Plot bounds */
+ char *mpdset; /* Map data set name */
+};
+
+/* Function prototypes for GX library routines */
+
+/* Functions in gxdev:
+ gxdbgn: Initialize hardware
+ gxdend: Terminate hardware
+ gxdfrm: New frame
+ gxdcol: New color
+ gxadcl: Assign rgb color
+ gxdwid: New line width
+ gxdmov: Move pen
+ gxddrw: Draw
+ gxdrec: Filled rectangle
+ gxdsgl: Set single buffer mode
+ gxddbl: Set doulbe buffer mode
+ gxdswp: Swap buffers
+ gxqfil: Query availability of hardware polygon fill
+ gxdfil: Hardware Polygon fill
+ gxdxsz: Resize X Window (X only)
+ gxdbtn: Get pointer pos at mouse btn press
+ gxgrey: Set grey scale
+ gxdbck: Set hardware background/foreground
+ gxrswd: Reset Widget Structures
+ gxcpwd: Copy widgets on swap in double buffer mode
+ gxevbn: Handle button press event
+ gxevrb: Handle rubber-band event
+ gxdptn: Set fill pattern
+ */
+
+void gxdbgn (float, float);
+void gxdend (void);
+void gxdfrm (int);
+void gxdcol (int);
+void gxdacl (int, int, int, int);
+void gxdwid (int);
+void gxdmov (float, float);
+void gxddrw (float, float);
+void gxdrec (float, float, float, float);
+void gxdsgl (void);
+void gxdbl (void);
+void gxdswp (void);
+int gxqfil (void);
+void gxdfil (float *, int);
+void gxdfl2 (float *, int);
+void gxdxsz (int, int);
+void gxgrey (int);
+void gxdbck (int);
+int gxdeve (int);
+void gxdbtn (int, float *, float *, int *, int *, int *, float *);
+void gxdpbn (int, struct gbtn *, int, int, int);
+void gxdrmu (int, struct gdmu *, int, int);
+void gxdsfn (void);
+void gxdtxt (char *, float, float);
+void gxdcf (void);
+int gxdfsw (char *, int, int);
+void gxdrdw (void);
+void gxrdrw (int);
+void gxrswd (int);
+void gxcpwd (void);
+void gxevbn (struct gevent *, int);
+void gxevrb (struct gevent *, int, int, int);
+int gxevdm (struct gevent *, int, int, int);
+int gxpopdm(struct gdmu *, int, int, int);
+void gxdrbb (int, int, float, float, float, float,int);
+char *gxdlg (char *);
+void gxdptn (int, int, int);
+void gxdssv (int);
+void gxdssh (int);
+void gxdsfr (int);
+
+/* Routines in gxsubs:
+ gxstrt: Initialize graphics output
+ gxend: Terminate graphics output
+ gxfrme: Start new frame
+ gxcolr: Set color attribute
+ gxacol: Assign new rgb to color number from 16-99
+ gxbckg: Set background color
+ gxqbck: Query background color
+ gxwide: Set line width attribute
+ gxmove: Move to X, Y
+ gxdraw: Draw solid line to X, Y using current color and linewidth
+ gxstyl: Set linestyle
+ gxplot: Move or draw using linestyles
+ gxclip: Set clipping region
+ gxchin: Initialize stroke font
+ gxchpl: Draw character(s)
+ gxtitl: Draw centered title
+ gxvpag: Set up virtual page
+ gxvcon: Do virtual page scaling
+ gxscal: Set up level 1 (linear) scaling
+ gxproj: Set up level 2 (projection) scaling
+ gxgrid: Set up level 3 (grid) scaling
+ gxback: Set up level 1 to level 2 back transform
+ gxconv: Convert coordinates to level 0 (hardware)
+ gxxy2w: Convert level 0 to level 2
+ gxcord: Convert array of coordinates to level 0
+ gxrset: Reset projection or grid level scaling
+ gxrecf: Draw filled rectangle
+ gxqclr: Query current color value
+ gxqstl: Query current linestyle value
+ gxmark: Draw marker
+ gxfill: Polygon fill
+ bdterp: Clipping Boundry Interpolation
+ gxgsym: Get env var
+ gxgnam: Get full path name
+ gxptrn: Set fill pattern
+ */
+
+void gxstrt (float, float,int);
+void gxend (void);
+void gxfrme (int);
+void gxsfrm (void);
+void gxcolr (int);
+void gxacol (int, int, int, int);
+void gxbckg (int);
+int gxqbck (void);
+void gxwide (int);
+void gxmove (float, float);
+void gxdraw (float, float);
+void gxstyl (int);
+void gxplot (float, float, int);
+void gxclip (float, float, float, float);
+void gxtitl (char *, float, float, float, float, float);
+void gxvpag (float, float, float, float, float, float);
+void gxvcon (float, float, float *, float *);
+void gxppvp (float, float, float *, float *);
+void gxscal (float, float, float, float, float, float, float, float);
+void gxproj ( void (*) (float, float, float*, float*) );
+void gxgrid ( void (*) (float, float, float*, float*) );
+void gxback ( void (*) (float, float, float*, float*) );
+void gxconv (float, float, float *, float *, int);
+void gxxy2w (float, float, float *, float *);
+void gxgrmp (float, float, float *, float *);
+void gxcord (float *, int, int);
+void gxpoly (float *, int, int);
+void gxrset (int);
+void gxrecf (float, float, float, float);
+int gxqclr (void);
+int gxqstl (void);
+void gxmark (int, float, float, float);
+void gxfill (float *, int);
+void bdterp (float, float, float, float, float *, float *);
+char *gxgsym(char *);
+char *gxgnam(char *);
+void gxptrn (int, int, int);
+
+/* Gxmeta routines handle graphics buffering and metafile output.
+ Routines in gxmeta:
+ gxhopt: Specify buffering option before open
+ gxhnew: Buffering initialization on startup
+ gxhbgn: Enable hardcopy (metafile) output
+ hout0: Buffer 0 arg metafile command
+ hout1: Buffer one arg metafile command
+ hout2: Buffer two arg metafile command
+ hout4: Buffer four arg metafile command
+ hout2i: Buffer two arg int metafile command
+ hout3i: Buffer three arg int metafile command
+ hout4i: Buffer four arg int metafile command
+ hfull: Deal with full metafile memory buffer
+ gxhprt: Handle print command (output to metafile)
+ gxhwri: Write buffer to metafile
+ gxhend: Close output metafile
+ gxhfrm: Handle new frame action
+ gxhdrw: Handle redraw operation
+ */
+
+void gxhopt (int);
+void gxhnew (float, float);
+int gxhbgn (char *);
+void hout0 (int);
+void hout1 (int, int);
+void hout2 (int, float, float);
+void hout4 (int, float, float, float, float);
+void hout2i (int, int, int);
+void hout3i (int, int, int, int);
+void hout4i (int, int, int, int, int);
+void hfull (void);
+void gxhprt (void);
+int gxhwri (void *, int);
+void gxhend (void);
+void gxhfrm (int);
+void gxhdrw (int);
+
+/* Routines in gxchpl:
+ gxchii: Initialize character plotting
+ gxchdf: Set default font
+ gxchpl: Plot character string
+ gxchln: Determine length (in plotting units) of a string
+ gxchgc: Get character info given character and font
+ gxchrd: Read in a font
+ */
+void gxchii (void);
+void gxchdf (int);
+void gxchpl (char *, int, float, float, float, float, float);
+int gxchln (char *, int, float, float *);
+char *gxchgc (int, int, int *);
+int gxchrd (int);
+
+/* Routine in gxcntr:
+ gxclmn: Specify minimum distance between labels
+ gxclev: Plot contour at specified value
+ gxcflw: Follow a contour segment
+ gxcspl: Spline fit a contour segment
+ gxclab: Draw buffered contour labels.
+ pathln: Find shortest col path through grid box
+ gxcrel: Release storage used by the contouring system
+ */
+void gxclmn (float);
+void gxclev (float *, int, int, int, int, int, int,
+ float, float, char *, int, int);
+void gxcflw (int, int, int, int);
+void gxcspl (void);
+void gxclab (float,int,int);
+int pathln (float, float, float, float);
+void gxcrel (void);
+
+/* Routines in gxshad -- color filled contour routine:
+
+ gxshad -- do color filled contours
+ gxsflw -- Follow shade area boundries
+ spathl -- Calculate col path lengths
+ undcol -- Determine undefined-grid-side col characteristics
+ putxy -- Buffer current coordinate
+ shdcmp -- Compress contour line
+ shdmax -- Determine max or min interior
+ */
+void gxshad ( float *, int, int, float *, int *, int, float);
+int gxsflw (int, int, int);
+int spathl (float, float, float, float);
+int undcol (int, int);
+int putxy (float, float);
+void shdcmp (void);
+int shdmax (void);
+
+/* routines in gxstrm: gxstrm (do streamlines) */
+
+void gxstrm (float *, float *, float *, int, int, float, float, float,
+ int, float *, int *, int, int);
+void strmar (float, float, float, float);
+int gxshdc (float *, int *, int, float);
+
+/* Routines in gxwmap:
+ gxwmap: Draw world map
+ gxnmap: Draw medium res n.am. map
+ gxmout: Output section of world map
+ gxnste: Set up projection scaling for north polar stereographic
+ gxnpst: Scaling routine for north polar stereographic projection
+ gxaarw: Direction adjustment for map projection
+ gxgmap: Medium and hi res map drawer
+ gxhqpt: Plot quadrant of medium or hi res map
+ */
+
+void gxdmap (struct mapopt *);
+void gxwmap (float, float, float, float);
+void gxnmap (float, float, float, float);
+void gxmout (int, float, float, float, float, float);
+int gxltln (struct mapprj *);
+int gxscld (struct mapprj *, int, int);
+int gxnste (struct mapprj *);
+void gxnpst (float, float, float *, float *);
+void gxnrev (float, float, float *, float *);
+int gxsste (struct mapprj *);
+void gxspst (float, float, float *, float *);
+void gxsrev (float, float, float *, float *);
+float gxaarw (float, float);
+void gxgmap (int, int, float, float, float, float);
+void gxhqpt (int, int, int, float, float, float, float, float);
+int gxrobi (struct mapprj *);
+void gxrobp (float, float, float *, float *);
+void gxrobb (float, float, float *, float *);
+/*---- DKRZ: appending new projections --- 10.08.95 Karin Meier
+
+ gxmoll: Setup scaling Mollweide projection
+ gxortg: Setup scaling Orthographic projection
+
+---- DKRZ: end of new projections --- karin.meier at dkrz.de ----*/
+
+/*---- Mollweide Projection ----*/
+
+int gxmoll (struct mapprj *);
+void gxmollp (float, float, float *, float *);
+void gxmollb (float, float, float *, float *);
+
+/*---- Orthographic Projection ----*/
+
+int gxortg (struct mapprj *);
+void gxortgp (float, float, float *, float *);
+void gxortgb (float, float, float *, float *);
+
+/*------- DKRZ appendingd end ------*/
+
+/*---- Lambert Conformal Projection ----*/
+
+int gxlamc (struct mapprj *);
+void gxlamcp (float, float, float *, float *);
+void gxlamcb (float, float, float *, float *);
+
+/*------- DKRZ appendingd end ------*/
diff --git a/include/cdTime/isdb.h b/include/cdTime/isdb.h
new file mode 100644
index 0000000..0b69e5e
--- /dev/null
+++ b/include/cdTime/isdb.h
@@ -0,0 +1,104 @@
+#ifndef ISDB_INCLUDE
+#define ISDB_INCLUDE
+
+/* max value from rand; HW/OS dependent */
+#define MAX_RAND 2147483647. /* SUN */
+/* #define MAX_RAND 32767. */ /* HP */
+
+#define NEONS_VRSN 3.6 /* release version of NEONS software */
+
+#define BYTE_BIT_CNT 8 /* count of bits per byte */
+#define WORD_BIT_CNT 32 /* count of bits per word */
+#define WORD_BYTE_CNT 4 /* count of bytes per word */
+
+#define OPN_RD 1 /* open database for read only */
+#define OPN_WR_RD 2 /* open database for write+read */
+
+#define MAX_FILE_CNT 15 /* maximum count of open files */
+
+#define ISDB_MODE 0666 /* mode for image files placed into db */
+#define LOCK_MODE 0200 /* mode for locking files while writing */
+#define INGEST_OWN "ingest" /* owner of image files before loaded in db */
+#define INGEST_MODE 0644 /* mode for ingest files before loaded in db */
+
+
+#define CLNDR_HOUR 0 /* calendar time, units = hours */
+#define CLIMO_DAY 1 /* climatology time, units = day in year */
+#define CLIMO_WEEK 2 /* climatology time, units = week in year */
+#define CLIMO_MONTH 3 /* climatology time, units = month in year */
+#define CLIMO_SEASON 4 /* climatology time, units = season in year */
+
+typedef struct { /* date structure */
+ int year; /* year number since 0 BC */
+ int month; /* month number in year */
+ int day; /* day number in month */
+ int type; /* time coordinate type */
+} DATE;
+
+typedef struct { /* info from table as_band */
+ long chan_num; /* channel number within sensor */
+ char band_name[31]; /* name of band */
+ long bit_cnt; /* count of bits in pixel */
+ float scl_fctr; /* scaling factor */
+ float reference; /* reference value */
+ char unit_name[31]; /* name of physical units */
+} AS_BAND;
+
+typedef struct { /* info from tables grid_reg_geom/as_reg_im */
+ char prjn_name[21]; /* projection name */
+ char stor_dsc[21]; /* (+x in +y)/(+x in -y)/(-y in +x)/etc */
+ 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 */
+ float x_int_dis; /* distance interval between columns in km */
+ float y_int_dis; /* distance interval between rows in km */
+ float parm_1; /* geom parm 1, depends on projection */
+ float parm_2; /* geom parm 2, depends on projection */
+ float parm_3; /* geom parm 3, depends on projection */
+} REG_GEOM;
+
+typedef struct { /* info from table as_sat_im */
+ long bgn_lin_num; /* beginning line number in orbit or pass */
+ long bgn_smp_num; /* beginning sample number in scan line */
+ long lin_int; /* lin interval relative to sensor scan mode */
+ long smp_int; /* smp interval relative to sensor scan mode */
+ float roll_ang; /* satellite roll angle in degrees */
+ float pch_ang; /* satellite pitch angle in degrees */
+ float yaw_ang; /* satellite yaw angle in degrees */
+} SAT_GEOM;
+
+typedef struct { /* info from table grid_spct_geom */
+ char stor_dsc[21]; /* (+x in +y)/(+x in -y)/(-y in +x)/etc */
+ 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) */
+} SPCT_GEOM;
+
+typedef struct { /* info from table sat_oe */
+ char seq_name[21]; /* orb-elem sequence name */
+ DATE date; /* date for orbital elements */
+ double hour; /* hour of day for orbital elements */
+ double parm_1; /* orb-elem parm 1 value */
+ double parm_2; /* orb-elem parm 2 value */
+ double parm_3; /* orb-elem parm 3 value */
+ double parm_4; /* orb-elem parm 4 value */
+ double parm_5; /* orb-elem parm 5 value */
+ double parm_6; /* orb-elem parm 6 value */
+ double parm_7; /* orb-elem parm 7 value */
+} ORB_ELEM;
+
+typedef struct { /* bit-map structure */
+ short lin_cnt; /* count of lines in bitmap */
+ short smp_cnt; /* count of samples per line in bitmap */
+ short pad_bit_cnt; /* count of bits for padding lines in bitmap */
+ short ofst_byte_cnt; /* byte offset into bitmap array where actual
+ bitmap data begins */
+ unsigned char *bmap; /* unsigned char array containing bitmap */
+} BITMAP;
+
+#endif /* ISDB_INCLUDE */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/cmor.git
More information about the debian-science-commits
mailing list